我们的产品由许多相互依赖的Maven项目组成.所有这些Maven项目都汇集在一个项目中,提供最终产品.
Maven项目共享相同的生命周期.换句话说,他们不是由单独的团队管理,他们有明确的<dependency>变化来获取其他项目的新版本.相反,当有人在某个项目中更改某些内容时,结果应该直接进入最终产品,而无需进行其他更改.
我们使用Jenkins作为持续集成工具.
我们的主要愿望如下:
pom.xml文件.问题:使用Jenkins执行此操作的最佳方法是什么?
我们目前正在考虑使用Jenkins Pipeline插件来使用单个作业,该插件分析Maven依赖关系和SCM更改,决定需要构建什么以及以何种顺序构建,然后实际构建项目.
maven jenkins maven-module jenkins-workflow maven-dependency
我正在创建一个新的java web项目.这个Web应用程序将有许多模块,如核心/公共,业务服务,存储库,安全性,集成,ldap,用户管理......我想知道是否应该将每个模块分成每个maven项目(jar文件)或创建项目包括所有模块的所有java包到单个maven项目中.
Structure of Multi modules maven project
mycompany-core
mycompany-repository
mycompany-api
mycompany-usermanagement
mycompany-business
mycompany-web
Structure of Single module project:
mycompany-web
|___ src
|____ main
|____ java
|____ com.mycompany.core
|____ com.mycompany.repository
|____ com.mycompany.business
|____ com.mycompany.controller
Run Code Online (Sandbox Code Playgroud)
什么时候应该应用多模块或单模块项目>请给我一些建议.
我正在使用多模块maven项目开发Java Web应用程序.项目设置如下:
pom.xml 主要的maven项目,包括以下模块:
persistence: 实体类和DAObusiness: 服务定义和实施webapp: Apache wicket Web应用程序依赖关系层次结构如下:webapp取决于business,取决于persistence.
我也使用Jetty Maven插件mvn -pl webapp jetty:run在主目录内部使用本地运行Web应用程序pom.xml.在开发应用程序时,在进行代码更改时,我希望jetty服务器重新启动并自动重新加载修改后的代码文件.当我修改里面的文件也能正常工作webapp的模块,但不工作,当我修改的另一个模块中的一个文件,这样persistence或business.
Maven Jetty插件的内部配置webapp/pom.xml如下:
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.2.2.v20140723</version>
<configuration>
<reload>automatic</reload>
<scanIntervalSeconds>1</scanIntervalSeconds>
<webApp>
<extraClasspath>../business/target/classes/;../persistence/target/classes/</extraClasspath>
</webApp>
<scanTargets>
<scanTarget>../business/target/classes</scanTarget>
<scanTarget>../persistence/target/classes</scanTarget>
</scanTargets>
</plugin>
Run Code Online (Sandbox Code Playgroud)
我按照这个答案的说明.该<scanTarget>标签做工精细,因为当我修改中的文件被码头重新启动business或persistence.但是,<extraClasspath>由于修改后的文件未被jetty加载,因此无效.链接的答案使用<webAppConfig>标记.但是,我正在使用插件文档中<webApp>指定的标记(我也尝试了旧标记,这导致了相同的结果).<webAppConfig>
我的问题是:如何为多模块项目配置Jetty Maven插件,以便从其他模块重新加载修改过的文件?
我有一个maven多模块项目,设计类似于以下SO帖子中的第一个答案: 带有Spring Boot的多模块maven
现在我想要一个通用的maven模块,它可以包含一些模型供多个微服务使用.如果我将这个常见项目作为第一级父pom的子项(这样所有依赖项通过引导注入,如jpa,jackson等可用于公共),那么STS/Spring将其检测为启动应用程序并抱怨没有Main关于maven构建的课程.
有人可以建议我如何实现这一目标吗?
现行代码:
parent pom.xml :(仅包含相关部分)
<project>
<name>...</name>
<groupId>...</groupId>
<artifactId>...</artifactId>
<packaging>pom</packaging>
<version>...</version>
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-parent</artifactId>
<version>Brixton.M3</version>
<relativePath />
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Run Code Online (Sandbox Code Playgroud)
子(公共模块)pom.xml(只有相关部分),不是启动应用程序:
<project>
<artifactId>...</artifactId>
<version>...</version>
<name>...</name>
<parent>
<groupId>...</groupId>
<artifactId>...</artifactId>
<version>...</version>
</parent>
</project>
Run Code Online (Sandbox Code Playgroud) 我已经将基于Spring Boot的项目拆分为几个Maven模块.现在只有war-project包含一个入门类(有一个main方法,启动Spring),其他模块都是jar类型.
如果他们不包含启动器,我如何测试jar项目?
示例JUnit测试用例标题:
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(StarterClassInDifferentProject.class)
...
Run Code Online (Sandbox Code Playgroud) 像这样的问题一直被问到,但不知怎的,他们只关注依赖性.因此,根据maven 文档,构建顺序确定如下.
- 项目依赖于构建中的另一个模块
- 插件声明,其中插件是构建中的另一个模块
- 插件依赖于构建中的另一个模块
- 构建中另一个模块的构建扩展声明
<modules>元素中声明的顺序(如果没有其他规则适用)
第一条规则是退出清除,例如,如果模块A依赖于模块B,则后者首先构建.
第五条规则(最后一条)也很清楚.如果前三条规则不适用,我们会查看模块部分中的顺序.
另外两条规则对我来说并不清楚.英语不是我的母语,但我想知道规则二是否包含某种拼写错误.
我正在寻找一个简单的例子来详细解释这两个规则.
我们使用git和maven-modules的maven-release-plugin有问题.
我们有以下项目结构:
pom.xml(ApplicationTest and ApplicationConf are modules)
ApplicationWeb
---pom.xml(parent pom in root folder)
ApplicationTest
---pom.xml(parent pom in root folder)
ApplicationConf
---pom.xml(All environments are modules. This has no parent pom)
---ConfDev
-------pom.xml(parent ApplicationConf)
---ConfTst
-------pom.xml(parent ApplicationConf)
---ConfAcc
-------pom.xml(parent ApplicationConf)
---ConfPrd
-------pom.xml(parent ApplicationConf)
Run Code Online (Sandbox Code Playgroud)
现在我们想发布dev config(Parent已经发布).这是通过在ApplicationConf/ConfDev/pom.xml上执行maven发布.
现在发布准备失败了,因为它在想要推送已更改的内容时使用了错误的git url.它附加了我们想要释放到git url的pom的工件id.
http://gitrepourl/git_repo.git/artifact-id
Run Code Online (Sandbox Code Playgroud)
我们在ApplicationConf中定义了pom中的scm设置,因此是所有环境的根.
<scm>
<developerConnection>scm:git:http://gitrepourl/git_repo.git</developerConnection>
</scm>
Run Code Online (Sandbox Code Playgroud)
我们是否有错误的项目结构,错误的设置或者这是maven-release-plugin中的错误?
使用版本:
maven-release-plugin 2.3.2和2.4.1
Maven 3.0.5
可能的方法:
从配置父pom中删除所有配置项目作为模块,并添加到每个pom更多scm信息,所以它看起来像这样:
<scm>
<url>https://github.com/XXX/YYY</url>
<connection>scm:git:ssh://git@github.com/XXX/YYY.git</connection>
<developerConnection>scm:git:ssh://git@github.com/XXX/YYY.git</developerConnection>
Run Code Online (Sandbox Code Playgroud)
现在我能够在每个pom上执行发布.这是正确的溶剂吗?
我试图将一组不相交的 maven 项目链接到一个标准的多模块项目中。
有趣的是,这些模块目前没有按自然层次结构排列。如果我与父 pom 链接在一起,那么在我添加relativePaths到子 pom XML 文件中的父节之前,反应器不会启动。
如果父版本与子版本中的 GAV 详细信息是正确的,并且子模块都在父 pom 中链接 - 这还不够吗?
简单来说 - 对于非标准目录结构,relativePath多模块 maven 项目是绝对必要的吗?
谢谢,艾斯
我想在某种全局项目目录中有一个模块,以便我可以将该模块包含在使用该公共代码的所有其他项目中。
但是我怎么能告诉 Maven 父级pom包含和编译这个全局共享模块呢?以下不起作用:
svn/MyGlobalProject/project-commons/pom.xml //should be shared among different projects
svn/MyProject/web-parent/trunk/pom.xml //the parent pom used to build the application
svn/MyProject/web-parent/trunk/project-domain/pom.xml //submodule 1
svn/MyProject/web-parent/trunk/project-web/pom.xml //submodule 2
Run Code Online (Sandbox Code Playgroud)
父 pom.xml:
<project>
<groupId>de.project</groupId>
<artifactId>project-parent</artifactId>
<packaging>pom</packaging>
<modules>
<module>project-domain</module>
<module>project-web</module>
<module>../project-commons</module> <!-- Error -->
</modules>
</project>
Run Code Online (Sandbox Code Playgroud)
mvn package 结果是:
Child module trunk\project-commons of trunk\pom.xml does not exist
Run Code Online (Sandbox Code Playgroud) the question was asked many times but I didnt find a solution, how to disable also the child modules of a module!?!
For example: I want to disable projects BB and CC AND also their child modules
A
|-AA
| |--AAA
|-BB
| |-BBB
|-CC
|-CCC
Run Code Online (Sandbox Code Playgroud)
But when I run this
mvn -pl \!AA,\!BB clean install
Run Code Online (Sandbox Code Playgroud)
I see that also BBB and CCC are executed. This here is only a sample. We have a multi module project with about a …