spring-boot-examples
spring-boot-examples copied to clipboard
关于模块管理的小建议
建议同时采用聚合和继承,使用<dependencyManagement>
管理 spring-boot-dependencies
,这样可以更方便的管理 SpringBoot 版本,也方便约束一些其它包(比如 mybatis-plus-boot-starter
)的版本,
比如/spring-boot-examples/pom.xml
:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>spring-boot-examples</artifactId>
<version>2.0.0</version>
<packaging>pom</packaging>
<modules>
<module>spring-boot-redis</module>
</modules>
<properties>
<java.version>11</java.version>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.3.7.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>
/spring-boot-examples/spring-boot-redis/pom.xml
:
<project >
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.example</groupId>
<artifactId>spring-boot-examples</artifactId>
<version>2.0.0</version>
</parent>
<artifactId>spring-boot-redis</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
</project>
模块管理还是很重要。 有很多包阿里镜像没有,想改一下版本发现每个模块的依赖都是独立的,很尴尬。 最后只能开代理从官方仓库中下载解决。
是的, 如果 spring-boot-examples 下没有 pom 还好, 既然选择了 module 还是完善更好些.