I have a problem: I need to create a jar from a web application (I'm using freemarker) and then refer this jar from within a different war.
In practice I need to follow the spring batch admin approach.
How can I do it?
I'm using spring for the first web app.
Many thanks
Related
I have recently learned how to work with Spring boot. Now, I have an application which works locally without any problem. Now, I would like to know how I can make it available as a website.
I have got a free web host from here and have followed the instructions to create a war file for my project. But I don't know what I should do with this war file and how I should use it to have my web page online.
In the meantime, my code is using Atlas Mongodb in it. Is using a database problematic? Should I consider something special for that?
Thanks in advance,
Shared hosting like 000webhost do not support Spring boot Hosting. As it was said earlier to host spring boot you have two choices either you host jar or war file. War is the traditional way of hosting it which needs Apache tomcat server and Jar is the Modern way which supports cloud based solutions. To host your solution you can create an account with AWS(Amazon web services) or GCP (Google Cloud Platform) and you will get free credits to use for a while or you can use Heroku(https://devcenter.heroku.com/articles/deploying-spring-boot-apps-to-heroku) which is pretty much easier to use, its free also. For the database if you are using (https://www.mongodb.com/cloud/atlas) then you are good. All the best
If you are using Spring Boot, which have an embedded tomcat. You can just pack your project to a jar file, put the jar file to the server, and then simply execute it on the network interface that can connect to the outside world.
If you would like to pack your project as a war file, then you should first install the environment (application server) like tomcat, glassfish, jboss, etc. After that, you can deploy the war file on the application server.
Likewise, you should install the database server on your host, and edit the spring application.properties to let your spring application connect to the database.
I have a project and I don't want to use AppEngine flex as they are expensive. So I converted my project to standard by converting spring boot application from jar to war
When I try to deploy the project to the app engine it is picking app.yaml rather appening-web.xml and deploying as a flex project rather standard.
Did anyone face the same?
Make sure your appengine-web.xml file is under the src/main/webapp/WEB-INF directory. Your structure should look lke this:
For more detailed information about the App Engine Standard configuration files for Java please check this documentation. You can also check the steps in this GitHub page on how to deploy a Spring Boot simple Hello World app in App Engine Standard.
Currently I'm deploying multiple war files into a Tomcat container. Is it possible to use Spring Boot to put all war files into a single deployable jar? I know this is possible for a single app, but can it be done to deploy multiple apps that once were in separate war files?
Spring Boot by design will run one app (one war) per container. If you want to go for the uber-jar deployment I suggest you stay with this since it is following also 12-factor-app best practices.
If you want to run multiple war files in one tomcat I suggest you follow the "old way" wrapping up your spring boot apps in war files and deploy them in an already set up tomcat or jetty or ...
So the answer will be: in principle – and with a lot of tweaking – you might be able to achieve what you are trying to do but this is not the intend of the jar distribution of spring boot apps. And always remember: work with the framework and not against it.
Tomcat container browses through the web apps and maps each war with the context root defined in it (single property of the web.xml). So, i do not think you can do merge the files in only one and still treat them as separate web apps.
What can be done is to actually merge the code of the web apps in only war file and split the functionality based on different paths after the context root path.
I'm using Sprint boot to run a web application. I did not configure any classes explicitly. I have a strange problem. When running the web server using gradle bootRun, I am able to access files that are directly under webapp folder but not a sub-folder like webapp/something.
I'm not posting any code here because there is nothing explicitly I configured different from a default spring boot web app. I'm using structure as in https://github.com/jhipster/jhipster-sample-app-gradle
Anyone faced this problem before ?
I am new to Spring MVC and I have now come accross tutorials that explain how to deploy your web project as a .jar. My IDE is the Spring Tool Suite. I have always used .war + Apache Tomcat.
Can someone elaborate a bit from the practical point of view why to use .jar instead of .war? Any problems to be aware of?
edit: other answers are welcome too
Spring Boot uses fat JAR packaging where is embeds Servlet container with all dependencies into this single JAR.
If you are using Maven, it uses spring-boot-maven-plugin to package the project.
Practical usage of this approach is simple. Ability to easily run Srvlet based Spring application from command line with externalized properties. Such configuration enables powerfully orchestration possibilities which are often used in modern enterprises in so called Microservices or SOA architecture.
There is group of people out there (including myself) which believe that deploying various WAR files of unrelated applications into single Servlet runtime is not very good idea.
So fat JARs are handy for separate Servlet runtime per application deployment.
About having .jar and Tomcat + .war on the same machine, it is possible and I use this. This may be not cool but I had a .war application running in a tomcat server before the rise up of spring boot. Now my new apps are spring boot apps, and we are migrating our architecture to SOA concept, but we can't change the tire with the moving car. The main application, the WAR is running in a tomcat server and the others (.jar) are self contained ( embedded tomcat ), each one running in a different port. It was the most viable solution available for us by the moment.