公共数据maven项目需要包含在两个spring-boot应用程序中



我有三个项目公共数据:独立的mavenjava项目应用程序1:春季启动应用程序应用程序2:春季启动应用程序

我想在应用程序和应用程序2中都包含该通用数据项目作为依赖项。但当我在application-1中添加依赖项时,spring-boot项目启动但未运行。

http://localhost:8090/hello这是终点:当在任何应用程序中包含公共数据的依赖项时,我得到404发现错误。

<dependencies>
<!-- Add typical dependencies for a web application -->
<!-- Adds Tomcat and Spring MVC, along others -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.stocksrin</groupId>
<artifactId>stocksrin-common</artifactId>
<version>1.0.0</version>
</dependency>

</dependencies>

现在这个不起作用

您可以这样做:

步骤1:编辑依赖关系org.stocksrin:

<dependency>
<groupId>org.stocksrin</groupId>
<artifactId>stocksrin-common</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${basedir}/lib/stocksrin-common.jar</systemPath>
</dependency>

${basedir}:项目根文件夹

步骤2:您可以将"includeSystemScope"设置为true:

<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>

最新更新