9

I have a WAR with Java Spring application, which I can deploy to a Java application server. I need to run it on a machine with JRE, but without application server, i.e. with java -jar my_application.jar.

The guide "Convert an existing application to Spring Boot" is a close match, except that I do not need to create a deployable WAR as I already have it. The existing code does not use @SpringBootApplication, and I'd prefer not to mangle with it.

Konstantin Shemyak
  • 2,369
  • 5
  • 21
  • 41

1 Answers1

2

If you want a runnable 'Jar' file, then the jar file must contain the Web server, so you best option is to convert your application to spring boot. Spring boot is able to package an application as a war file, so it can be deployed on a Tomcat, or be launched with java -jar, but it has to be a spring boot app to begin with.

Klaus Groenbaek
  • 4,820
  • 2
  • 15
  • 30
  • 1
    Yes, I'm exactly looking for a way to get Spring boot app from my existing code with minimal modifications - preferably only additions. The question is, how to do that. – Konstantin Shemyak Jan 03 '17 at 20:12
  • 1
    http://stackoverflow.com/questions/23868580/one-spring-boot-project-deploy-to-both-jar-or-war – Klaus Groenbaek Jan 03 '17 at 20:19
  • I have not tried it myself, but one of the other developers made it work. I was interested in how they solved the class loader scoping with Tomcat, which is in it self an interesting read http://docs.spring.io/spring-boot/docs/current/reference/html/executable-jar.html – Klaus Groenbaek Jan 03 '17 at 20:21
  • I has renamed`.war` to `.jar` and all works! – Sherzod Mar 04 '21 at 11:38