The gradle can build runnable jar made by spring boot to war file? - spring-boot

I made my application using spring boot. It use embedded servlet container using tomcat library and run as application. Because I use spring boot annotation in main class for running. I used it in the local, But I have to make this application buidld war file to send the remote server where tomcat instance is listening.
First, I want to ask this gradle plugin I found can to it to generate the war file even if it have a main class and doesn't follow original webapp style
Second, Is there any other gradle plugin to send the war to the remote server and make tomcat redeploy the war file I sent?
Thanks in advance.

It seems to me that you have the answer to your first question in the documentation. Spring Boot war is nothing different from traditional war so I am not sure I understand what you mean. Perhaps Converting a Spring Boot JAR Application to a WAR would help?
For your second question gradle remote deploy war on Google gave me this

Related

Spring Boot with maven war dependancy

I have Spring Boot web project with dependency to maven overlay war file which is also Spring web project. War is included in pom.xml.
How can I deploy that war along with Spring Boot application so I can use rest endpoints that belong to war file. I'm trying to start application from STS simply by running it as Java application. While application is starting, I can see only URLs that belong to Spring Boot project, but URLs that belong to war file are missing.
I believe Spring boot does not support that. See issue here
Try building a war and deploying it into a container.

How to create deployable springboot war

I am trying to create a maven spring boot application to be deployed in Tomcat. I am following what is suggested in Spring docs and other stackoverflow suggestions- war, Application.java extending SpringBootServletInitializer, removing spring-boot-maven-plugin from build plugins etc. War file is generated and is deployed in tomcat. But what I found is all static files are packaged under /WEB-INF/classes folder and I am not able to access the page. My project structure is as below:
Can anybody tell me how I can package the war properly to be deployed in Tomcat.
That doesn't change anything.
If you put your static assets in src/main/resources/static (and they end up in WEB-INF/classes/static), Spring Boot will serve them properly. So a src/main/resources/static/foo.png will be available at http://localhost:8080/your-context/foo.png if the context of your webapp is your-context.
Regarding the configuration, you can also go on start.spring.io, click advanced and chose war and you'll get an empty project pre-configured.
Or you can click this: https://start.spring.io/#!packaging=war
The issue is because of version issue. I compiled the application with Java 8 and deployed it in tomcat running under JRE 7. It may help someone facing the same issue.
I got the clue from the below post:
Spring boot war file deploy on Tomcat.

Spring boot App - .war welcome file list config

I use Spring boot embedded container and it works fine. Now, moving to war file deployment duo to some restriction on .jar with webapp folder. Not sure how to configure welcome file list with Spring boot war.
Thanks
Perhaps this answer could be of assistance
Changing default welcome-page for spring-boot application deployed as a war

Spring Boot Gradle - avoid lib-provided folder in war file

I have a Spring Boot based application and I'm trying to switch over from Maven to Gradle. The application is supposed to build a war file, which is deployed to a web server (WildFly in our case).
Now, I have some libraries provided by the web server and thus using a "providedCompile" scope (For hibernate search and infinispan). Now, when used with Spring Boot plugin, the plugin is creating the war file with all the "providedCompile" libraries moved to a folder named "lib-provided".
How do I avoid this? On the same context, it is also adding the Spring Boot loader classes on to the war file. If possible, I need to avoid this too.
Please help! Thanks!
If you're only ever going to deploy your application as a WAR file to an app server, then you don't need it to be turned into an executable archive. You can disable this repackaging in your build.gradle file:
bootRepackage {
enabled = false
}

Deploying a 'JAR' file instead of 'WAR' file for Spring-MVC and Maven

I am working on a Spring-MVC application which uses Maven. In the POM.xml I noticed that I can denote the file-type in which I can select if I want to deploy the project as a JAR or WAR.
Mostly I select a WAR file and then deploy it in Apache tomcat. My question is, If the application is Spring-MVC based, with Spring-Security, Hibernate and other libraries, can I package it as JAR by simply denoting it in POM.xml and deploy it in Apache webserver instead of using Apache tomcat? Or do I need to make some modifications somewhere for this to work. Kindly let me know. Thank you.
No, you can't. Apache httpd knows nothing about how to handle jar files.
What you can do though is to provided an embedded webserver (such as jetty) in your package and define in your MANIFEST.MF file a main class that will launch it and register your application to it.
That way you can package is a an auto-executable jar, or as a war that can be run on his own or deployed in a classical webserver.

Resources