idea搭建springCloud----搭建父子项目(二)

今天介绍一下 : idea 搭建父子项目

https://start.spring.io  

因为这个网站实在国外,经常连接超时,所以将其更换成阿里云连接:https://start.aliyun.com/  速度杠杠的,

但注意:请使用idea 2018.2  版本以上的!!!   我用2014版的试过,问题连连,,,

不得感叹一下,阿里真的很牛皮!!!

父项目:springCloud_ht

子项目:eureka_server(注册中心)

1-1.新建父项目:

 1-2 起名称 springCloud_ht

 1-3 什么都不选,next

 1-4 :起项目名称:springCloud_ht

 

1-5: 该目录为下图,但是项目为红色,我不喜欢红色,去除红色(将svn删掉,刷新即可)

1-6 :删除不必要的文件

2 创建子项目

2-1 创建maven模块

2-2  创建子项目:

 2-3  创建项目名:eureka_server

2-4:选择:spring web Starter 和  eureka server

2-5  起项目名:

2-6 项目路径:

2-7 点击pom.xml 添加为maven项目

2-8 :查看项目:

 2-9   将注解:@EnableEurekaServer  添加到  EurekaServerApplication 类上

2-10  完善配置文件: application.yml

server:
  port: 8761

eureka:
  instance:
    hostname: localhost
  client:
    registerWithEureka: false
    fetchRegistry: false
    serviceUrl:
      defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/

2-11  启动main方法,访问路径:http://localhost:8761/

 注意:现在其实还没有父子相连!!!!

在父pom.xml文件中添加:

<modules>
<module>子项目名称</module>
</modules>

<packaging>pom</packaging>

 

在子pom.xml文件中添加:

<parent>
<groupId>父组信息</groupId>
<artifactId>父名称</artifactId>
<version>父版本</version>
</parent>

现在就可以重新启动了,父子之间可以对应了

搭建过程可以参考   方志朋的博客:https://www.fangzhipeng.com/springcloud/2017/06/01/sc01-eureka.html

 

 

 

posted @ 2019-07-19 16:30  宗贵涛  阅读(990)  评论(0编辑  收藏  举报