我需要帮助。我有2个spring-boot-jar项目Maven基础,我想像图片一样将第一个导入到第二个
我在配置Spring-Boot中导入Util Jar作为打击并运行Spring Boot,但这显示错误
<dependency>
<groupId>com.ballistic</groupId>
<artifactId>adminutil</artifactId>
<version>0.1</version>
</dependency>
[错误]无法在项目配置上执行目标org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile(默认编译):编译失败:编译失败:
Pom.xm Util-Jar
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.ballistic</groupId>
<artifactId>adminutil</artifactId>
<version>0.1</version>
<packaging>jar</packaging>
<name>adminutil</name>
<description>
Util For Admin Tool Help In All Jar's
</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Add Log4j2 Dependency -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
<!-- Needed for Async Logging with Log4j 2 -->
<dependency>
<groupId>com.lmax</groupId>
<artifactId>disruptor</artifactId>
<version>3.4.0</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
Pom.xm Config Jar
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.ballistic</groupId>
<artifactId>config</artifactId>
<version>0.0.1</version>
<packaging>jar</packaging>
<name>config</name>
<!--
mvn install:install-file -Dfile=C:\Users\AdMaxim\Desktop\App\adminutil\target\adminutil-0.1.jar -DgroupId=com.ballistic -DartifactId=adminutil -Dversion=0.1 -Dpackaging=jar
-->
<description>
Config Help The Configuration Of All Sub Jar
</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>com.ballistic</groupId>
<artifactId>adminutil</artifactId>
<version>0.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
</plugins>
</build>
答案 0 :(得分:0)
您必须为此使用重新包装。
默认情况下,重新包装目标将用 重新包装的。对于表示以下内容的模块,这是理智的行为 一个应用程序,但是如果您的模块用作另一个模块的依赖项, 您需要为重新包装的商品提供分类器。
原因是应用程序类打包在 BOOT-INF / classes,以便从属模块无法加载重新打包的 jar的课程。如果是这种情况,或者您希望保留 原始工件,然后将重新包装的工件与其他工件附加在一起 分类器,如下配置插件:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.4.1.RELEASE</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<classifier>exec</classifier>
</configuration>
</execution>
</executions>
...
</plugin>
或者您也可以声明主类。
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>YourMainClass.java</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>