我搭建了一个spring-boot2.0的maven项目,多个模块。项目能运行,但是在mvn install时报错:
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /G:/workspace1/pmp/admin/src/main/java/com/sdcm/admin/dao/TestDao.java:[3,34] 程序包com.sdcm.common.utils.date不存在
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.946 s
[INFO] Finished at: 2018-05-24T10:29:59+08:00
[INFO] Final Memory: 38M/285M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project admin: Compilation failure
[ERROR] /G:/workspace1/pmp/admin/src/main/java/com/sdcm/admin/dao/TestDao.java:[3,34] 程序包com.sdcm.common.utils.date不存在
[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
---------------------------------------------------------------------------------------------------------------------------------------------------------------
自己百度,也到各种群里问过,但是还是不能解决,特来求教wendal大神,虽然不是nutz相关,但是大神是善良的对吗?
下面附上说明:
1.项目叫pmp,里面有一个主pom,pmp下有两个子模块,admin和common,admin依赖common,当admin中不import common中
的类时,admin 的mvn install正常,import后就报错如上。但是admin能用main方法正常启动且无报错。
-----初步怀疑是admin的pom里面的build不对,下面贴上
2. admin的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.sdcm</groupId>
<artifactId>admin</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>admin</name>
<description>pmp权限控制模块</description>
<!-- 声明父模块,继承父模块的依赖 -->
<parent>
<groupId>com.sdcm</groupId>
<artifactId>pmp</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<properties>
<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>com.sdcm</groupId>
<artifactId>common</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
- common的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.sdcm</groupId>
<artifactId>common</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>common</name>
<description>pmp公共模块</description>
<!-- 声明父模块,继承父模块的依赖 -->
<parent>
<groupId>com.sdcm</groupId>
<artifactId>pmp</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
@wendal