My project is running fine in eclipse. I was using the following plugin to build my jar with dependencies.
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<archive>
<manifest>
<mainClass>com.project.App</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
On running the jar, I got the following error.
2017-07-17 15:21:06.825 ERROR 17587 --- [
main] o.s.boot.SpringApplication :
Application startup failed
org.springframework.beans.factory.BeanDefinitionStoreException:
Failed to process import candidates for configuration class [com.project.App];
nested exception is java.lang.IllegalArgumentException:
No auto configuration classes found in META-INF/spring.factories.
If you are using a custom packaging, make sure that file is correct.
I found this solution to use spring-boot-maven-plugin and modified my code as shown below.
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
<mainClass>com.project.App</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
The error was fixed. However, the jar created through this process does not contain dependencies. Is it possible to build jar with dependencies using spring-boot-maven-plugin? Kindly suggest a solution.
Just use it and run with mvn clean package
evething will be okay.
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<addResources>false</addResources>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>your.main.class</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
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.