现在的一个项目,架构不知道谁搭的,这个就不吐槽了。
P 下有 modules(a,b,c,d)。每个 module 都是一个 Spirng Boot 的项目(指的是 a,b,c 都有一个类似结构的类。除类名外,均与以下代码一样
`
@
SpringBootApplication @
EnableCaching public class XXXBaseApplication {
}
`
)。modules c/d 均有引用 a 的代码,d 项目是主要开发项目,在 IDEA 中可以直接运行 d 项目。
现在的问题是,我想将 d 项目打成 jar 包。尝试在项目 p 下直接
`mvn package`,结果 a 报
`Execution default of goal org.springframework.boot:spring-boot-maven-plugin:1.5.4.RELEASE:repackage failed: Unable to find main class -> [Help 1]
`
在 a 的 Main 类中加入空的 main 方法(b/c 中也同样加入),a 可正常打包,c 打包失败,提示
`[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project c: Compilation failure
[ERROR] c/src/main/java/xx/XX.java:[8,27] 找不到符号
[ERROR] 符号: 类 BaseEntity
[ERROR] -> [Help 1]
`
其中的 BaseEntity 是 a 中的基类。
a pom
` <parent>
<groupId>xx</groupId>
<artifactId>p</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>apollo-login</artifactId>
<dependencies>
...
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
</configuration>
</plugin>
</plugins>
</build>
`
c pom
` <parent>
<groupId>xx</groupId>
<artifactId>p</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>c</artifactId>
<dependencies>
<dependency>
<groupId>xx</groupId>
<artifactId>a</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
</plugins>
</build>
`
d 的 pom 与 c 类似。
在 不大动 项目架构的前提下,如何能保证项目正常打包?