“Cannot resolve symbol” when trying to import classes from a jar deployed in my custom maven nexus repo

白昼怎懂夜的黑 提交于 2020-07-10 07:42:22

问题


It's not my first time reading deployed jars from my custom maven nexus repo (my setting.xml is correctly written ), but unfortunately, this time I wasn't able to import classes from a new deployed spring-boot jar, although it does exist in the project classpath.

Cannot resolve symbol 'test'

ps: the jar code snippet in my pom.xml is as below

       <project> 
     ...
        <dependency>
                <groupId>cc.test</groupId>
                <artifactId>jar-name</artifactId>
                <version>0.1.4</version>
            </dependency> 
    ....
 </project>

回答1:


Quick update:

After trying almost everything, I found the solution! Shortly a Spring Boot application is not intended to be used as a dependency, thus adding the below configs will generate two separate jars, your application’s executable fat jar will be published with an exec classifier. The normal jar that can be used as a dependency will be unclassified. this unclassified jar will be deployed in your maven nexus repo, and used as a maven dependency in another spring-boot project

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

My response is based on spring-boot official documentation:

https://docs.spring.io/spring-boot/docs/2.1.1.RELEASE/reference/htmlsingle/#howto-create-an-additional-executable-jar



来源:https://stackoverflow.com/questions/62516343/cannot-resolve-symbol-when-trying-to-import-classes-from-a-jar-deployed-in-my

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!