After some radical changes to our schema and reading some posts on why you should avoid in memory databases.
We have decided to use MySQL locally for testing and developing. Using a MySQL docker container with a volume for persistence.
This is fairly straightforward however the issues we are having are the following:
Requires the container to be executed separate from the spring boot application (a manual task docker run
Same goes for stopping the container, its a independant process
My question is essentially, is it possible to have spring boot (when using a dev config profile) to manage this docker container.
i.e. I start development work in IntelliJ and run the service, the service checks if the container is running, if not starts it up.
If this idea is bad, then please let me know.
For testing its not issue, because we are using a maven docker plugin to create the container during the maven lifecycle.
Its more for devs working locally, and getting the service running locally with ease.
Any suggestions welcomed!
Bonus for Intellij setup!
Related
I have a web app built with Java, Spring MVC, and JDBC. The result is a WAR file.
To run it, the user has to install Java 8 JDK and Tomcat, and deploy the WAR file to the Tomcat server.
It would be great if they could just download the one file run it as a standalone application.
That is, run "the WAR file" and just browse to http://localhost:8080/myapp
Also, on Windows it would be great it was setup as a Server (like Tomcat is when installed with the installer).
Is there any way to do this? Maybe with Spring Boot or something new like that?
Yep, Spring boot is the way to go.
It allows you to build an executable Jar with all dependencies and a Tomcat (by default, can be changed) embedded.
But users will still need to download a JRE to execute the Jar, and a database if it's required, but you can use en embedded database like H2, HSQLDB..., depends what is your needs.
Yes . you can use spring boot to achieve your results. Kindly refer the below link for sample code
https://mkyong.com/spring-boot/spring-boot-hello-world-example-jsp/
You can use embedded jetty server using maven but that would require you to setup few things your app and may have align your existing app, please check this article for more information.
Jetty is similar to tomcat server in terms of running spring application, there are not much difference in terms of development. Tomcat is just more famous.
Other option as others said, is to migrate your app to spring boot which would be easy if you already have app written in spring (But that depends how much code you have and how much time you have)
We currently running an app on production on tomcat 8.0.44.
We migrated our app to work on spring boot v2.0.4 (embedded tomcat) and now we need to upload it to production (instead of the tomcat implementation)
Could someone share his experience regarding this transfer?
Any impact noticed? All aspects (load, performance, etc), any downsides?
What should we consider when doing this transfer? (load test is problematic due to the nature of our application)
Also, I understood that spring boot can run as executable (currently not implemented on QA). What are the benefits of using it? is it preferable as to using java to run spring boot (the regular way)? any downsides?
Thanks,
Hila
I have a regular Java/Spring Batch job that runs every night to get data from one database and insert/update in my project's database. This is working fine in the current setup where it is deployed on Tomcat.
Now I need to separate it out and run it on an Azure WebJob. What will be a good approach?
Can I use Spring Boot for this purpose?
But I am not sure how it will work. I mean, I can create a JAR of my project (Job written using Spring Boot) and copy it on a Azure WebJob. Then have a batch file with "java -jar..." but:
wouldn't it be like running and deploying the Spring Boot App with it's inbuilt web-server that will continue to run once I run it?
secondly, the next time the batch file is executed by Azure WebJob as per the schedule I set it will try to run the Spring Boot App again and I will probably get bind exception since the port is already in use from the first run.
Would appreciate if somebody can help me in doing this.
Thank you.
wouldn't it be like running and deploying the Spring Boot App with it's inbuilt web-server that will continue to run once I run it?
A Spring Boot app can be a non web app, and a good example is a Spring Boot batch app without a dependency to a servlet container.
You can create a Spring Boot app that runs your Spring Batch job and then stops when the job is finished without the need to deploy it in a (embedded) Tomcat. You can find an example here: https://spring.io/guides/gs/batch-processing/
secondly, the next time the batch file is executed by Azure WebJob as per the schedule I set it will try to run the Spring Boot App again and I will probably get bind exception since the port is already in use from the first run.
Once you have a script to run your app with java -jar mybatchapp.jar, you can use Azure Scheduler to run your job when you want. Since your batch app does not contain/start an embedded servlet container, you won't get a port conflict.
I have developed a micro service (Spring Boot REST service, deployed as executable JAR) to track all activities from third party projects as my requirement and its working now.
Currently it's working apart of some projects, and now I have updated service with some additional features.
But I can't move it to live server without restarting the existing service as it is deployed as jar. I'm afraid to restart my service, restart may be leads to lose data of integrated projects.
What improvements can I make in my architecture to solve my problem?
What about JRebel plugin. It worked perfectly for me, but, unfortunately, it's not a free app. Like alternative, (i used this approach with Spring MVC, with Spring Boot it could be otherwise), I set up a soft link in work directory on a compiled path in JBoss (in my case it was dir with name target and *.class and *.jar files). As for me, the first solution with JRebel is the most appropriate for you.
Finally got a solution as commented by #Gimby .
We can do it by deploying multiple instances of services and it bound to a service registry ,Here i achieved it by using eureka as registry service and also used zuul as proxy .
I'd like to know the main differences between CloudFoundry and Google App Engine for a personnal project.
I have a web application that currently runs on GAE and i'am thinking to move it to CloudFoundry for various technical reasons.
I'd like to use :
Spring MVC & Spring Security.
a full implementation of JPA instead of DataNucleus.
mavenize my project properly, i can't make the maven-gae-plugin works.
Is CloudFoundry a good alternative to GAE in my case?
What is the complexity of the migration?
Thanks
It shouldn't be too hard to migrate the app.
http://blog.springsource.org/2011/11/10/using-cloud-foundry-services-with-spring-part-4-%E2%80%93-spring-profiles/ and the whole series of articles has lot of details on how to bind your Spring app to a cloudfoundry data source.
http://blog.springsource.com/2011/09/22/rapid-cloud-foundry-deployments-with-maven/ has details about the cloudfoundry maven plugin, for deployment
To migrate your data, you may want to use the remote api http://code.google.com/appengine/docs/java/tools/remoteapi.html or bulkloader to export, then CloudFoundry Caldecott to import your data in CloudFoundry http://blog.cloudfoundry.com/post/12928974099/now-you-can-tunnel-into-any-cloud-foundry-data-service
http://start.cloudfoundry.com/frameworks/java/spring/spring.html the getting started in cloudfoundry for spring is a good place to start learning about deploying spring apps to cloudfoundry.
I hope this helps.
I can only answer the maven part: see this for a working multimodule example: https://github.com/leanengine/LeanEngine-Server
you must use it like this:
mvn gae:unpack // downloads GAE classes to your maven repo
mvn clean install package
cd lean-server-example
mvn gae:execute // starts a local server