赞
踩
在IDE中构建普通maven项目,作为父项目。需要新增微服务,则在项目下新建module,每一个微服务是独立的模块。
主要在父pom.xml中管理maven依赖,主要依赖如下:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${springcloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-dependencies -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${springboot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>${mysql.version}</version> </dependency> <!-- https://mvnrepository.com/artifact/com.alibaba/druid --> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> <version>${druid.version}</version> </dependency> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>${mybatis.version}</version> </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>
以上依赖均放置于dependencyManagement
依赖管理节点中。
<dependencyManagement>
<dependencies>
</dependencies>
</dependencyManagement>
pom文件中,dependencyManagement
节点表示依赖管理,统一在父项目pom.xml文件中管理版本号。
dependencyManagement
中已经存在,则在 dependency
节点中只需指定groupId
、artifactId
,IDEA会默认指向父项目中的依赖,此时不需要指定版本号。dependencyManagement
中不存在,子模块的dependency
节点要指定完整的gav坐标。更多:
Spring cloud微服务搭建(二)——pojo实体类
Spring cloud微服务搭建(三)—— Spring cloud服务提供方
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。