[英]flatten-maven-plugin deploy multi module project
parent project maven父项目maven
<modelVersion>4.0.0</modelVersion>
<groupId>groupId</groupId>
<artifactId>artifactId</artifactId>
<packaging>pom</packaging>
<version>${revision}</version>
<modules>
<module>module1</module>
<module>module2</module>
</modules>
<properties>
<revision>0.1.10-SNAPSHOT</revision>
</properties>
<build>
<plugins>
<plugin>
flatten-maven-plugin
...
</plugin>
</plugin>
<build>
child 1 module孩子 1 个模块
<parent>
<artifactId>artifactId</artifactId>
<groupId>groupId</groupId>
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>module1</artifactId>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
child 2 module孩子 2 模块
<parent>
<artifactId>artifactId</artifactId>
<groupId>groupId</groupId>
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>module2</artifactId>
<dependencies>
<dependency>
<groupId>groupId</groupId>
<artifactId>module1</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
module1 is a springboot project which should be packaged to a executable jar, and module2 should be deployed to nexus Now, module2 is uploaded to nexus successfully but module1 unable to start by java -jar module1是springboot项目,应该打包成可执行jar,module2应该部署到nexus 现在,module2已经成功上传到nexus,但是module1无法通过java -jar启动
add build in module1 can fix the problem在module1中添加构建可以解决问题
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>{version}</version>
<configuration>{mainClass}</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
When you create a jar for your module, that jar must have all the dependency jar within it.当您为您的模块创建 jar 时,该 jar 必须在其中包含所有依赖项 jar。 This type of jar is called a Fat jar or executable jar.
这种类型的 jar 称为胖 jar 或可执行 jar。 Add below tag in you pom.xml of module1 which will create and package all the dependency jars within it.
在你的 pom.xml 的 module1 中添加下面的标签,这将在其中创建 package 所有依赖项 jars。 Note: I can see that you have already added the "spring-boot-maven-plugin" but you have missed to provide your Spring boot main class and repackage goal.
注意:我可以看到您已经添加了“spring-boot-maven-plugin”,但您错过了提供 Spring 引导主 class 和重新打包目标。
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>{Your spring boot main class}</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.