Ikbel
Ikbel

Reputation: 2203

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

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>

Upvotes: 0

Views: 671

Answers (1)

Ikbel
Ikbel

Reputation: 2203

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

Upvotes: 1

Related Questions