java – 父pom和微服务器
>我们有几个项目是微服务器,每个项目都是独立的(运行在单独的弹簧引导服务器上,露出休息服务,使用单独的数据库模式…)
>我们使用maven来管理依赖项. 有一个父母pom将每个微服务声明为模块是个好主意?因此,有助于管理常见的依赖关系(例如,在每个项目中使用lib servlet-api witch,将其全部删除并仅在父pom中声明) 解决方法
多模块父pom的“问题”是,没有复杂的配置文件,它会将模块锁定在相同的发行周期(假设您正在使用
Release Plugin,您应该).
我与Maven一起工作的方式是拥有一个声明为父母的pom: >通用依赖项(记录API,JUnit等). 每个模块将父pom作为其父对象,但父对此模块无关. 这样做的好处来自上面的最后两颗子弹,“管理”部分.在“管理”部分中包含的任何内容需要在要使用特定依赖项或插件的模块中重新声明. 例如,父母可能看起来像这样: <project> <groupId>com.example</groupId> <artifactId>parent</artifactId> <version>1.0.00-SNAPSHOT</version> ... <dependencies> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.7.7</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.11</version> <scope>test</scope> </dependency> </dependencies> <dependencyManagement> <dependency> <groupId>commons-lang</groupId> <artifactId>commons-lang</artifactId> <version>2.6</version> </dependency> <dependency> <groupId>commons-collections</groupId> <artifactId>commons-collections</artifactId> <version>2.1</version> </dependency> </dependencyManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> <plugins> <pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <version>2.4</version> <configuration> <appendAssemblyId>false</appendAssemblyId> <descriptors> <descriptor>src/main/assembly/assembly.xml</descriptor> </descriptors> </configuration> <executions> <execution> <id>make-assembly</id> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin> </plugins> </pluginManagement> </project> 并且模块可能如下所示: <project> <parent> <groupId>com.example</groupId> <artifactId>parent</artifactId> <version>1.0.00-SNAPSHOT</version> </parent> <groupId>com.example</groupId> <artifactId>module</artifactId> <version>1.0.00-SNAPSHOT</version> <dependencies> <dependency> <groupId>commons-lang</groupId> <artifactId>commons-lang</artifactId> </dependency> </dependencies> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> </plugin> </plugins> </project> 该模块将: >依赖于org.slf4j:slf4j-api:1.7.7:compile,junit:junit:4.11:test and commons-lang:commons-lang:2.6:compile.>有插件org.apache.maven.plugins:maven-assembly-plugin:2.4 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- Hibernate rowCount方法:返回满足条件的记录的数
- spring-boot通过@Scheduled配置定时任务及定时任
- 如何将缺少.project .settings .classpath文件的
- java – 如何使用Ebean查询具有onetomany和manyt
- java – 在Mockito中保留默认值
- java – 在SpriteBatch.begin / end中嵌套ShapeR
- 在tomcat上运行非web java应用程序
- java – Integer.parseInt()抛出带有UTF-8文件
- java – JDK 1.4.2中String类中的“contains(Cha
- android日志打印工具类