How can I deploy the war file to the embedded Tomcat server of the Spring boot application, which is offline INSIDE?

I have a server module that depends on web modules:

 <dependency> <groupId>org.ema.server</groupId> <artifactId>web</artifactId> <version>0.0.1-SNAPSHOT</version> <type>war</type> </dependency> 

which gets repackaged using spring-boot-maven-plugin to get standalone:

 <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <fork>true</fork> <mainClass>org.ema.server.Server</mainClass> </configuration> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin> 

Everything is still working. The web module is included in the final bank as BOOT-INF/lib/web-0.0.1-SNAPSHOT.war .

I know that Spring allows you to load additional war files for Tomcat at run time , but it looks like such a war file should be located somewhere in the file system, or I'm doing it wrong.

The question is, how can I maintain a standalone feel, but can I still add war files to my final standalone jar and deploy them to the built-in Tomcat?

Below is the code that shows how to do this, but I'm not sure that this can be done the way I require it:

 @Bean public EmbeddedServletContainerFactory servletContainerFactory() { LOGGER.info("Adding web app"); return new TomcatEmbeddedServletContainerFactory() { @Override protected TomcatEmbeddedServletContainer getTomcatEmbeddedServletContainer(Tomcat tomcat) { // Ignore that since it not working anyway. String resourcePath = getClass().getResource("/../lib/web-0.0.1-SNAPSHOT.war").getPath().toString(); try { tomcat.addWebapp("/web", resourcePath); } catch (ServletException ex) { throw new IllegalStateException("Failed to add webapp", ex); } return super.getTomcatEmbeddedServletContainer(tomcat); } }; } 
+7
spring boot tomcat
source share

No one has answered this question yet.

See similar questions:

27
Spring Download: how to add another WAR file to the built-in tomcat?
2
Set Tomcat Resource in Spring
one
How to upload an external โ€œmilitaryโ€ file to the spring boot tomcat embedded server

or similar:

708
How to configure port for Spring Boot application
275
How to deploy a war file in Tomcat 7
27
Spring Download: how to add another WAR file to the built-in tomcat?
8
Spring-Boot Logging configuration when deployed as .war
6
Spring War boot file works with built-in, but not standalone Tomcat
2
How to deploy WAR-WAR WAR for Tomcat?
0
Unable to access deployed WAR file on Tomcat
0
tomcat7 - How to deploy a war file with spring boot
0
Tomcat ignores application.properties of Spring Boot war application deployed on standalone server
0
War with spring battle without lib on tomcat 8

All Articles