gpt4 book ai didi

java - Maven多模块项目打包报错

转载 作者:行者123 更新时间:2023-11-29 07:25:39 25 4
gpt4 key购买 nike

我正在尝试使用 Maven 开发多模块项目。但是当我想打包我的项目时它会出错。

它说网络类中不存在包。我已经在问答部分尝试了解决方案。但是没有用。你能检查一下我的代码库并告诉我哪里做错了吗?

[INFO] 8 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] xguru .............................................. SUCCESS [ 1.330 s]
[INFO] data ............................................... SUCCESS [ 5.453 s]
[INFO] web ................................................ FAILURE [ 0.746 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.064 s
[INFO] Finished at: 2018-12-04T12:15:14+03:00
[INFO] Final Memory: 48M/391M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:testCompile (default-testCompile) on project web: Compilation failure: Compilation failure:
[ERROR] /C:/Users/asus/IdeaProjects/xguru/web/src/test/java/com/alikaan/xguru/controller/OwnerControllerTest.java:[3,31] package com.alikaan.xguru.model does not exist
[ERROR] /C:/Users/asus/IdeaProjects/xguru/web/src/test/java/com/alikaan/xguru/controller/OwnerControllerTest.java:[4,33] package com.alikaan.xguru.service does not exist
[ERROR] /C:/Users/asus/IdeaProjects/xguru/web/src/test/java/com/alikaan/xguru/controller/OwnerControllerTest.java:[32,13] cannot find symbol
[ERROR] symbol: class OwnerService
[ERROR] location: class com.alikaan.xguru.controller.OwnerControllerTest
[ERROR] /C:/Users/asus/IdeaProjects/xguru/web/src/test/java/com/alikaan/xguru/controller/OwnerControllerTest.java:[37,9] cannot find symbol
[ERROR] symbol: class Owner
[ERROR] location: class com.alikaan.xguru.controller.OwnerControllerTest
[ERROR] /C:/Users/asus/IdeaProjects/xguru/web/src/test/java/com/alikaan/xguru/controller/OwnerControllerTest.java:[45,9] cannot find symbol
[ERROR] symbol: class Owner
[ERROR] location: class com.alikaan.xguru.controller.OwnerControllerTest
[ERROR] /C:/Users/asus/IdeaProjects/xguru/web/src/test/java/com/alikaan/xguru/controller/OwnerControllerTest.java:[45,25] cannot find symbol
[ERROR] symbol: class Owner
[ERROR] location: class com.alikaan.xguru.controller.OwnerControllerTest
[ERROR] /C:/Users/asus/IdeaProjects/xguru/web/src/test/java/com/alikaan/xguru/controller/OwnerControllerTest.java:[46,9] cannot find symbol
[ERROR] symbol: class Owner
[ERROR] location: class com.alikaan.xguru.controller.OwnerControllerTest
[ERROR] /C:/Users/asus/IdeaProjects/xguru/web/src/test/java/com/alikaan/xguru/controller/OwnerControllerTest.java:[46,26] cannot find symbol
[ERROR] symbol: class Owner
[ERROR] location: class com.alikaan.xguru.controller.OwnerControllerTest
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :web

Process finished with exit code 1

这是我的 pom.xml 文件:

家长:

<?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>

<groupId>com.alikaan</groupId>
<artifactId>xguru</artifactId>
<version>0.0.1-SNAPSHOT</version>
<modules>
<module>data</module>
<module>web</module>
</modules>
<packaging>pom</packaging>


<name>xguru</name>
<description>Demo project for Spring Boot</description>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>


<properties>
<start-class>com.alikaan.xguru.XguruApplication</start-class>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>

<dependencies>
<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>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<configuration>
<goals>install</goals>
<autoVersionSubmodules>true</autoVersionSubmodules>
</configuration>
</plugin>
</plugins>
</build>


</project>

网络:

<?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">
<parent>
<artifactId>xguru</artifactId>
<groupId>com.alikaan</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>web</artifactId>

<dependencies>
<dependency>
<groupId>com.alikaan</groupId>
<artifactId>data</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>2.23.4</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<configuration>
<!--Required to get circleCI working-->
<useSystemClassLoader>false</useSystemClassLoader>
</configuration>
</plugin>
</plugins>
</build>

</project>

数据:

<?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">
<parent>
<artifactId>xguru</artifactId>
<groupId>com.alikaan</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>data</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>2.23.4</version>
<scope>test</scope>
</dependency>

</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<!--Note your version numbe might be different-->
<version>2.22.1</version>
<configuration>
<useSystemClassLoader>false</useSystemClassLoader>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<skip>true</skip>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

最佳答案

我通过将这个添加到数据 pom 来弄清楚

   <properties>
<spring-boot.repackage.skip>true</spring-boot.repackage.skip>
</properties>

关于java - Maven多模块项目打包报错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53609881/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com