I have a Spring Boot project that I would like to use as a dependency in another project.
First, in my pom.xml, I set the packaging tag to jar. However, that produced a jar with a BOOT-INF folder, which could not be imported inside the other project. In order to fix that, I added the following lines:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.4.2</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
Now, when I run mvn clean package
two jars are generated:
BOOT-INF\lib
folder (containing the dependencies)I would like to make it so the first jar also contains the libraries.
Please add this in pom.xml and try again.
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
Note - There is no need to add a class with the main method, so you can remove a similar class like this.
@SpringBootApplication
public class DemoApplication{
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.