记一次mvn clean install 报package com.rockysaas.shopguide.common.config.threadpool does not exist

Posted zjhgx

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了记一次mvn clean install 报package com.rockysaas.shopguide.common.config.threadpool does not exist相关的知识,希望对你有一定的参考价值。

最近在导购项目中增加了两个模块,common,job. 原先的admin,web还有job引用了common包。其中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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.rockysaas.shopguide</groupId>
        <artifactId>shopguide-parent</artifactId>
        <version>1.0.0</version>
    </parent>
    <groupId>com.rockysaas.shopguide</groupId>
    <artifactId>common</artifactId>
    <version>1.0.0</version>
    <name>common</name>
    <packaging>jar</packaging>

    <description>Common project for ShopGuide</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.8</version>
        </dependency>

        <dependency>
            <groupId>cn.hutool</groupId>
            <artifactId>hutool-all</artifactId>
            <version>4.5.1</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

admin的pom.xml引用到了common包

  <dependencies>
 。。。
        <dependency>
            <groupId>com.rockysaas.shopguide</groupId>
            <artifactId>common</artifactId>
        </dependency>
。。。
</dependencies>

admin项目引用了common里的变量

import com.rockysaas.shopguide.common.config.threadpool.ThreadPoolProperties;
@Component
@ConfigurationProperties(prefix = "task.threadpool.executor")
public class TaskThreadPoolProperties extends ThreadPoolProperties {
}

但是整个项目mvn clean install -Dmaven.test.skip=true 时却报了

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project admin: Compilation failure: Compilation failure:

在idea中启动项目没问题也没报编译错误,而且我在job项目里引入common的变量后也有这个问题。经过几个小时的实验和测试,发现问题是在common的pom.xml里加上了

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

把这个去掉就一切正常。这个插件是启动springboot项目服务时用的,但common只是一个包,并不需要启动服务。看来对一些东西不是特别清楚时乱加就是会出各种问题。

以上是关于记一次mvn clean install 报package com.rockysaas.shopguide.common.config.threadpool does not exist的主要内容,如果未能解决你的问题,请参考以下文章

mvn install 包含 mvn clean吗

“mvn clean install”和“mvn clean verify install”有啥区别?

“mvn clean install”与“mvn install”有何不同?

mvn clean package install deploy

如何在eclipse中使用mvn clean install

Run “mvn clean install” in Eclipse