包不存在mvn clean install

时间:2017-06-27 11:29:09

标签: java maven compiler-errors pom.xml

我正在使用这种结构处理多模块maven项目:

ats-parent有3个孩子:ats-api,ats-client,ats-impl

ats-impl有4个孩子:ats-accountManager,ats-common,ats-noticeManager,ats-applicationContext。

此外,ats-common取决于ats-api。

所以这是我的问题:

当我尝试运行mvn clean install时出现错误:

/home/frozen/workspace/ATS/ats-parent/ats-impl/ats-common/src/main/java/com/o2xp/ats/common/services/ti/CategoryService.java:[5,31] package com.o2xp.ats.api.common does not exist

我确切地认为,常见的CategoryService会将某些类用于ats-api。此外,我检查了详细日志,我指的是与api模块中的类导入相对应的行

这是ats-common的pom:

<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <artifactId>ats-impl</artifactId>
    <groupId>com.o2xp</groupId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>
  <packaging>jar</packaging>
  <artifactId>ats-common</artifactId>
  <name>ats-common</name>
  <url>http://maven.apache.org</url>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
  <dependencies>
    <dependency>
        <groupId>com.o2xp</groupId>
        <artifactId>ats-api</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <type>jar</type>
    </dependency>
  </dependencies>
</project>

ats-api的pom:

<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <url>http://maven.apache.org</url>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <start-class>com.o2xp.ats.accountManager.App</start-class>    
  </properties>
  <parent>
    <groupId>com.o2xp</groupId>
    <artifactId>ats-parent</artifactId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>
  <packaging>jar</packaging>
  <groupId>com.o2xp</groupId>
  <artifactId>ats-api</artifactId>
  <name>ats-api</name>
  <dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
    </dependency>
  </dependencies>

</project>

和ats-impl的pom:

<?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>
   <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>    
                </configuration>
            </plugin>
        </plugins>
    </build>
  <packaging>pom</packaging>
  <groupId>com.o2xp</groupId>
  <artifactId>ats-impl</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>ats-impl</name>
  <url>http://maven.apache.org</url>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
  <dependencies>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <version>1.4.196</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <version>1.5.3.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-data-jpa</artifactId>
      <version>1.5.3.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-test</artifactId>
      <version>1.5.3.RELEASE</version>
      <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
        <version>1.5.3.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot</artifactId>
        <version>1.5.3.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-security</artifactId>
      <version>1.5.3.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.mapstruct</groupId>
        <artifactId>mapstruct-processor</artifactId>
        <version>1.1.0.Final</version>
    </dependency>
    <dependency>
        <groupId>io.github.jhipster</groupId>
        <artifactId>jhipster</artifactId>
        <version>1.1.6</version>
    </dependency>
  </dependencies>
  <modules>
    <module>ats-application-context</module>
    <module>ats-notice-manager</module>
    <module>ats-common</module>
    <module>ats-accountManager</module>
  </modules>
</project>

除了ats-accountManager之外,其他模块都被编译了,因为它是在ats-common之后被跳过了。

2 个答案:

答案 0 :(得分:0)

com.o2xp.ats.api.common属于您的api模块。

更改

 <modules>
 <module>ats-application-context</module>
 <module>ats-notice-manager</module>
 <module>ats-common</module>
 <module>ats-accountManager</module>
</modules>

 <modules>
    <module>ats-application-context</module>
    <module>ats-notice-manager</module>
    <module>ats-accountManager</module>
  </modules>

ats-common模块将由ats-api模块

构建

答案 1 :(得分:0)

我在我的ats-parent pom中找到了解决方案我添加了春季启动作为父母我刚删除它并且它正在工作