I had a Spring MVC project that I'm converting to spring boot. This project of mine cannot be given spring-boot-starter-parent
as parent because I need to keep a custom parent.
I solved this first issue by injecting spring-boot-dependencies
in dependencyManagement.
I also need my project to embed a tomcat, so I've used spring-boot-starter-web
. I need to use JSP so i've added the dependencies to jstl
and jasper
.
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.1.4.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-loader -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-loader</artifactId>
<version>2.1.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<!-- ... -->
</dependencies>
Compiling the jar and launching the server using
mvn spring-boot:run
correctly works. Now I'd like to make it work as executable jar, too.
I have read some documentation, posts, web pages, stack overflow questions, but I still cannot make it properly work.
In this question, reading the edited version of the accepted answer and the github project it looks very easy to make an executable jar out of a project having as parent spring-boot-starter-parent
. Is it possible to make it work with a custom parent too?
I have already tried to follow these guidelines but it doesn't work with my project. I tried adding the plugin
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
both with and without the execution
node
and the plugin
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<archive>
<manifestFile>src/main/webapp/META-INF/MANIFEST.MF</manifestFile>
</archive>
<!-- <archive>-->
<!-- <manifest>-->
<!-- <mainClass>my-boot-application</mainClass>-->
<!-- <springBootClasses>WEB-INF/classes/</springBootClasses>-->
<!-- <springBootLib>WEB-INF/lib/</springBootLib>-->
<!-- </manifest>-->
<!-- </archive>-->
</configuration>
</plugin>
both with and without the manifest
customized information.