I want to create a separate jar by excluding some packages with its own artifactId and use it as a dependency in another project

6 views
Skip to first unread message

socalled coders

unread,
Jun 12, 2023, 4:41:04 AM6/12/23
to Getting started with Spring Framework
Main pom.xml
===========


<project>

...

<groupId>com.company.entity</groupId>

<artifactId>entity-api</artifactId>

<dependencies>

...

</dependencies> 


<build>

<plugins>

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-jar-plugin</artifactId>

<executions>

<execution>

<id>entity-service</id>

<phase>package</phase>

<goals>

<goal>jar</goal>

</goals>

<configuration>

<classifier>service</classifier>

<archive>

<manifest>

<addClasspath>true</addClasspath>

<mainClass>com/company/entity/EntityAPIApplication</mainClass>

</manifest>

</archive>

<excludes>

<exclude>**/com/company/*/controller/**</exclude>

</excludes>

</configuration>

</execution>

</executions>

</plugin>

</plugins>

</build>

</project>


but after running this in command line it is raising this error

>>>>>>>>>>>>


C:\Users\rkaparav\Desktop\check excluded or not from jar>java -jar entity-api-0.1.0-SNAPSHOT-service.jar
Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/boot/SpringApplication
        at com.company.entity.EntityAPIApplication.main(EntityAPIApplication.java:17)
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.SpringApplication
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        ... 1 more


please help me to make that jar a runnable spring boot application

socalled coders

unread,
Jun 12, 2023, 4:42:11 AM6/12/23
to Getting started with Spring Framework
It is successfully excluding the packages but raising error regarding spring application class loader
Reply all
Reply to author
Forward
0 new messages