I would like to see a spring boot sample that lets me do:
mvn tomcat:run
I tried existing samples and following tutorials but with no luck.
The official documentation is not very clear about this, but I've found this concise and easy how-to to put spring boot and tomcat maven plugin all together.
https://gerrydevstory.com/2014/08/22/spring-boot-and-the-embedded-tomcat-container/
The gist of the information on the site:
Remove spring-boot-maven-plugin <plugin> configuration on pom.xml
Setup tomcat7-maven-plugin <plugin>
.
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
</plugin>
.
@Configuration
@EnableAutoConfiguration
@ComponentScan
public class Application extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
}
And change the scope in POM.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With