I have spring boot application , a microservice
I can run it without any problem as Spring boot application
mvn clean compile spring-boot:run
Now if I try to deploy it in tomcat 9, am getting ClassNotFoundException, shows as if am missing some jar I tried adding the missing jar for one application , but it keeps coming for newer applications. There are no steps involved in here, compile ,test as standadlone, then package and deploy to tomcat.
What could be the issue. I guess the actual log is not needed here as the problem seems to be very generic
The Answer is simple, plain and stupid. If you face any similar issue, just make sure , you are running a similar version of tomcat.
My spring boot application worked fine, when ran using mvn spring-boot:run
but my actual tomcat server was bit older, so it was missing few libraries.
Upgrading the tomcat version fixed it
First of all, Spring boot doesn't require a container, You can execute using java -jar yourspsringboot.war
In your pom, Are you compiling it as war with dependencies? If so, verify that under WEB-INF/lib directory. If you not able to find the dependencies in lib directory then it should be the issue.
Please include following build tag in your pom. Create new build a deploy. It will work. I also faced this issue.
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.5.3.RELEASE</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
<configuration>
<useSystemClassLoader>false</useSystemClassLoader>
</configuration>
</plugin>
</plugins>
</build>
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.