3

I have published my artifact to Maven. Can be accessed here -> https://oss.sonatype.org/#nexus-search;classname~AccessGateLabs

Thereafter, I have added the dependency,

<dependency>
   <groupId>com.accessgatelabs.oss</groupId>
   <artifactId>response-builder</artifactId>
   <version>1.0.2</version>
</dependency>

The dependency got added and I can see the jar inside the Maven dependency folder (screenshot attached) Screenshot of Dependency got added

After this, I am unable to import the class from this dependency.

enter image description here

Thanks!

ekansh
  • 716
  • 8
  • 16
  • 2
    to be a standard "jar" dependency, I think your packages `com.accessgatelas.oss.builder` should not be below a BOOT-INF folder. I'm unsure they can be found there. – Marc Le Bihan Jun 03 '20 at 10:37
  • 1
    you probably published the spring-boot uber jar. But this is not suitable to be used as a dependency in maven. Spring Boot will add a classloader to the jar to load the classes and libs from inside the repacked jar. For the purpose of having an executable jar. I don't think that is your intention here? If you plan to re-use the functionality somewhere else (in another Spring Boot application) I would suggest to remove the spring-boot plugin from your build and publish a normal jar and pom file. Then have it added as a dependency in a build/app that does have that plugin enabled. – wemu Jun 03 '20 at 10:53
  • Yes, it worked after removing Spring plugin for packaging. Thanks! – ekansh Jun 03 '20 at 11:57

1 Answers1

1

The problem is that you have deployed an uber-jar containing Sping classes, not your own library with you classes. You see in the archive browser when browsing the jar that the root directory is "org/springframework/boot"

The solution is to not use the Spring plugin for packaging, but the default maven jar packaging plugin.

pdem
  • 3,880
  • 1
  • 24
  • 38