How to make my spring boot application online on my domain? - spring

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.

Related

Does every spring boot application create a tomcat container to be able to run?

For example,
I understand adding specific dependencies like spring-boot-starter-web that contains tomcat as transitive dependency triggers the spring framework to initialize tomcat container but I want to know if we say a spring-boot application is running, does it imply always that tomcat is also running?
I want to know if we say a spring-boot application is running, does it imply always that tomcat is also running?
No, it doesn't.
Spring boot can be used for both web applications and non-web applications.
For web applications you can use tomcat/jetty/undertow/netty for example, its up to you to chose what works for you the best.
If you don't want to run an embedded version of the web server you can opt for creating a WAR file and place it into the web server prepared in-advance.
If you don't want to run web application at all (something that is built around "Request - Response" way of work in the most broad sense) - you can create a "CommandLineRunner" - in this case you don't need to depend on neither web-mvc nor webflux. For more information about Command Line Runners read here for example
You can have an embedded server in your JAR that is able to be run on its own. By default it is Tomcat but you can change this to others, like Jetty. Additional details:
https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/html/howto-embedded-web-servers.html
If you don't want to have an embedded server and you want to deploy your application you can also create WAR files instead of JAR files. Additional details:
https://www.baeldung.com/spring-boot-no-web-server
https://spring.io/guides/gs/convert-jar-to-war/

Spring Boot REST Deployment: do we need TomCat?

I've seen Spring Boot Rest project that generates WAR then deployed in a tomcat container. I wonder if this is best practice because I've also read that in Spring Boot, the new final executable JAR file contains embedded server solution like Tomcat too?
Now i've seen a related post that talks about Spring Boot supports both ways but none talked about the pros and cons of each.
Can someone point out the best practice for deploying a spring boot rest project?
I'm thinking of dockerizing the JAR containing embedded server but i'm wondering if there's any drawbacks vs deploying WAR to Tomcat?
A general best practice ( from 12 Factor App ) regarding the application environment and dependencies is "Explicitly declare and isolate dependencies".
A twelve-factor app never relies on implicit existence of system-wide
packages
With that in mind one should gravitate more towards using embedded container as part of explicit dependency instead of a requirement that needs to be fulfilled separately.There are multiple choices for embedded container in the jar artifact (like tomcat, jetty, undertow, netty) and their respective configuration is also extensive, so using these in production environment is recommended ( I have used them a lot). However there might be certain times when you would want to create a war instead, for e.g., a war file will be deployable in any full-fledged EE Application server ( Weblogic, Wildfly etc) which might be mandated by your environment. With a war, your number of options in terms of app server increases. Personally for me, spring boot jar with embedded tomcat has been quite effective. With embedded container option what you need is a virtual machine with OS and Java installed and you are good to go.
However there is a special limitation related to JSP as mentioned here in Spring Boot documentaion which explain a good reason why you might need to package as a war but still run as jar.

What is recommended while using spring boot in production deployment (jar/war)

I have an interesting decision to take for my project.
We use spring boot for our micro services.
The development environment is spring boot wíth tomcat in the embedded mode.
However, I am not sure if there are any advantages/ drawbacks if I choose this way in production too.
The counter argument is to deploy a war in a separate tomcat.
I am not able to think on any buying points for both views
What will be the best choice for a large enterprise production system on cloud(jar/war)?
I saw some recommendations here (but I need more stronger reasons to chosse/ not choose any one): Spring boot embedded container or war file in an external container for production
here are my points to use fat jar for production deployment.
fat jars are simple to build and deploy.
Spring Boot aims to be production ready, by default. This means that
it ships with useful defaults out of the box that may be
overriden, if necessary.
Fat JARs are good for running as the microservices as managing
microservices is already a burden then why one more step to
configure and deployment should be considered.
fat jar can also run as a java service easy to manage by a single command, restart server/jvm can be managed automatically.
Spring boot is Embedded with- Tomcat, Jetty and Undertow so changing
app server for any micro services is not a big deal.

Spring Framework hosting

I am trying Java with Spring Framework for my own web project. I've asked some traditional JSP web hosting firms which supports Tomcat and they said they do not support Spring Framework. I am confused about this situation. What is the different requirements between JSP and Spring Framework? I was thinking both of them runs on JVM such as Tomcat and they do not need any difference things. Does Spring Framework need different jar files, or different software on server?
Building a Spring application results in a jar with an embedded webserver (most of the times tomcat, but you can change this in the pom.xml/build.gradle).
I used to host my Spring applications on a VPS or Amazon EC2 instance. Something like that. You can just install Java on it and run your jar. No extra installations of webservers needed.
Ok, let get it straight, just summarizing what have been said:
Use Spring MVC, without spring boot.
Use Spring Boot, and create a war file.

How to integrate a SpringSource dm Server into another OSGi-based application server?

I would really like to use SpringSource dm Server, but our customer requires us to run our apps on their application server (Websphere). Is there a way to integrate SpringSource dm Server with other application servers? At least dm Server is build on OSGi, and many other application servers (including Websphere) are based on OSGi as well. Is it possible to run a SpringSource dm Server as a websphere component?
SpringSource dm Server is based on the Eclipse Equinox OSGi framework (and should not be confused with the Spring DM technology, included in dm Server, which can run on Equinox, Apache Felix, and Knopflerfish).
However, embedding dm Server in another application server, such as WebSphere Application Server, based on Equinox would be a non-trivial piece of work. It would be necessary to get both products to use the same version of Equinox, which they currently do not, then modify dm Server to support embedding in the server (e.g. to integrate with the host server's application invocation mechanism, thread pools, and class loading scheme).
If you think this support is important, please raise a requirement (which requires a simple registration) against dm Server.
Spring DM is deployed on a Knoplerfish OSGi implementation.
Websphere is deployed on an Equinox OSGi implmentation.
So the question becomes - are the two interchangeable? They both support R4, so I would say, yes, they are.
The next question would be to check dependencies, particularly with respect to things like HttpServices.
I would say this would be ok, but I think the final proof would be try deploying it. Easiest would be to drop the bundles into a Websphere deployment. You'll need your bundles and whatever spring bundles you're using.
I'm also interested in this topic. Another way of looking at this problem is that you want an application depoyable in both Spring dm server and a traditional app server (Websphere, weblogic, JBoss, ...).
The OSGi containers are embeddable inside non-OSGi applications, so it is theoretically possible to deploy an app to both Spring dm server and the same app + OSGi container to a traditional app server.
Now, as usual, the devil's in the details, including such topics of web development and bridging servlets between the outer app server and the OSGi container.
I do not think that this is really the case ...
see the following link for this: http://apsblog.burtongroup.com/2008/11/websphere-7-osgi.html
But it seems on the other side, that the trend is clear ... there will be a time when OSGI based application can be deployed on Java EE application servers

Resources