common模块pom.xml 不需要build(maven-plugin之类)
添加了就会报下面的错
/root/.jenkins/workspace/Controller.java:[6,34] package com.common.utils does not exist
原因:因为如果common已经进行build成common.jar,依赖common的其他模块在进行构建的时候,会把common.jar再build一次,导致后面显示找不到指定的类
解决方案:common模块不需要添加build构建插件
其他普通模块:只需要添加
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<!-- 指定版本和goals-->
<version>${spring.boot.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- 如果有Dockerfile-->
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>1.3.6</version>
<configuration>
<repository>${project.artifactId}</repository>
<buildArgs>
<JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE>
</buildArgs>
</configuration>
</plugin>
</plugins>
同时父模块添加
<packaging>pom</packaging>
如果出现 diamond operator is not supported in -source 1.5
说明maven默认使用的是1.5进行编译,需要使用1.8进行编译。
解决方案:修改/opt/maven/conf/settings.xml路径下全局配置文件为
<profiles>
<profile>
<id>jdk1.8</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.8</jdk>
</activation>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
</properties>
</profile>
</profiles>
<activeProfiles>
<activeProfile>jdk1.8</activeProfile>
</activeProfiles>