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>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章