我有一个 Maven 多模块项目,其设计类似于以下 SO 帖子中的第一个答案: Multi-module maven with Spring Boot
现在我想要一个通用的 maven 模块,它可以包含一些供多个微服务使用的模型。如果我将这个公共项目作为第一级父 pom 的子项目(以便所有通过引导注入的依赖项,如 jpa、jackson 等都可用于公共),那么 STS/Spring 将其检测为引导应用程序并抱怨没有 Main Maven 构建类。
有人可以建议我如何实现这一目标吗?
当前代码:
父 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>
子(公共模块)pom.xml(仅相关部分),不是启动应用程序:
<project>
<artifactId>...</artifactId>
<version>...</version>
<name>...</name>
<parent>
<groupId>...</groupId>
<artifactId>...</artifactId>
<version>...</version>
</parent>
</project>