maven install的时候报错,提示程序或引用找不到,明码写着common类找不到

前言

我是再把springcloud项目导成jar包的时候出现的问题,在导Erueka注册中心的时候没问题,因为Erueka注册中心不需要common类的实体类,可在导服务的时候就出了问题,提示找不到common类里面的实体类

问题图片

在这里插入图片描述
全部代码:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project microservice-student-consumer-feign-80: Compilation failure: Compilation failure: 
[ERROR] /D:/temp/idea-workspase/helloIdea/springcloud/microservice-student-consumer-feign-80/src/main/java/com/liwangwang/microservicestudentconsumerfeign80/controller/StudentConsumerController.java:[3,48] 程序包com.liwangwang.microservicecommon.entity不存在
[ERROR] /D:/temp/idea-workspase/helloIdea/springcloud/microservice-student-consumer-feign-80/src/main/java/com/liwangwang/microservicestudentconsumerfeign80/controller/StudentConsumerController.java:[4,49] 程序包com.liwangwang.microservicecommon.service不存在
[ERROR] /D:/temp/idea-workspase/helloIdea/springcloud/microservice-student-consumer-feign-80/src/main/java/com/liwangwang/microservicestudentconsumerfeign80/controller/StudentConsumerController.java:[17,13] 找不到符号
[ERROR]   符号:   类 StudentClientService
[ERROR]   位置: 类 com.liwangwang.microservicestudentconsumerfeign80.controller.StudentConsumerController
[ERROR] /D:/temp/idea-workspase/helloIdea/springcloud/microservice-student-consumer-feign-80/src/main/java/com/liwangwang/microservicestudentconsumerfeign80/controller/StudentConsumerController.java:[23,26] 找不到符号
[ERROR]   符号:   类 Student
[ERROR]   位置: 类 com.liwangwang.microservicestudentconsumerfeign80.controller.StudentConsumerController
[ERROR] /D:/temp/idea-workspase/helloIdea/springcloud/microservice-student-consumer-feign-80/src/main/java/com/liwangwang/microservicestudentconsumerfeign80/controller/StudentConsumerController.java:[28,17] 找不到符号
[ERROR]   符号:   类 Student
[ERROR]   位置: 类 com.liwangwang.microservicestudentconsumerfeign80.controller.StudentConsumerController
[ERROR] /D:/temp/idea-workspase/helloIdea/springcloud/microservice-student-consumer-feign-80/src/main/java/com/liwangwang/microservicestudentconsumerfeign80/controller/StudentConsumerController.java:[33,12] 找不到符号
[ERROR]   符号:   类 Student
[ERROR]   位置: 类 com.liwangwang.microservicestudentconsumerfeign80.controller.StudentConsumerController
[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

解决问题

用这个插件打包的Jar包可以直接运行,但是不可依赖。
所以interface自始至终就没有依赖,自然会说找程序包不存在或者找不到类
源代码:

 <build>
        <plugins>
            <!--添加maven插件-->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>

                <configuration>
                    <!--添加自己的启动类路径!-->
                    <mainClass>com.liwangwang.microservicecommon.MicroserviceCommonApplication</mainClass>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <!--可以把依赖的包都打包到生成的Jar包中-->
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

修改后的common: (其他的配置文件不需要改)

 <build>
        <plugins>
            <!--添加maven插件-->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>

                <configuration>
                    <classifier>execute</classifier>
                    <!--添加自己的启动类路径!-->
                    <mainClass>com.liwangwang.microservicecommon.MicroserviceCommonApplication</mainClass>
                </configuration>
                <executions>
                    <execution>
                    	<phase>none</phase>
                        <goals>
                            <!--可以把依赖的包都打包到生成的Jar包中-->
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
发布了143 篇原创文章 · 获赞 136 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/weixin_43943548/article/details/103390116
今日推荐