SpringBoot + SpringBatch Clean Install executes Batch Job - spring-boot

Not sure if anyone else has experienced this, but I created a simple spring boot + spring batch job, and everytime I do a maven clean, install, the batch job runs. Not really what people are looking for, but all my jobs do the same thing.
I followed some threads and you can add a property for:
spring.batch.job.enabled=false
but when I do that the maven clean install works find, but then when you run the main boot file, it doesn't run the job either.
Starting to not like this Boot framework for Spring Batch jobs.

You have a test that is running the Boot application. The default test from https://start.spring.io will do that. Remove that test and you should be fine (unless you have any other tests that do launch your Boot application).

Related

Debug Spring Boot 3 in IntelliJ Community

Since the migration to Spring Boot 3 my application doesn't hold at breakpoints any more, when I run the Maven Spring Boot goal mvn spring-boot:run.
This is because Spring forks the thread or the process and the debugger is not attached to this.
In former Spring-Boot versions you could disable forking by passing -Dspring-boot.run.fork=false (see How to debug spring-boot application with IntelliJ IDEA community Edition?).
Unfortunatly this option was removed as you can read in the Spring Boot 3.0 Migration Guide:
The fork attribute of spring-boot:run and spring-boot:start that was deprecated in Spring Boot 2.7 has been removed.
Is there any possibility to make breakpoints work again?
Ideas so far
Of course IntelliJ Ultimate has better Spring Boot integration. I'm trying to make it work with the Community Edition.
I also tried not to run the Maven goal but to make an Application run configuration. This failed so far, because of java.lang.ClassNotFoundException, it doesn't find the Main class. Not sure if I should investigate that option further.
Last idea was to start the Maven goal with debug options such that an external debugger can attach. That didn't work either and even if it would, I could only attach the debuger after startup with would make debugging the creation of spring context impossible.

Spring Boot written in Spring Tool Suite make automatically udate by all tasks, if i make a change in only one task. How to stop this problem, please?

My question is about Spring Boot written in STS. If while working I make a change at the level of a project in a task, all the other projects automatically update and display the same modifications in the other tasks. How can I stop this?

What can i do to not re-run gradle spring boot application again and again

I've one gradle spring boot project. Even if i'd to put one log at some place. It requires re-run of the application. Is there anyway to add these type of changes on the fly when application is running (on my local system).
For some cases, hot reload which is JVM feature should do the trick

Spring Boot Maven plugin - spring-boot:run and production

Is it a good idea or practice to start a Spring Boot application at production with a following command of Spring Boot Maven plugin ?
mvn spring-boot:run
No, this is a bad idea.
You would re-build your project on every run which means that you would pull all needed dependencies on each new VM / container.
Also using the spring-boot-maven-plugin in conjunction with the dev-tools for example would lead to options that you don't want in production.
This ranges from using other database settings to disabled caching mechanisms for your templating engine.
Use the executable jar instead.
If you want to run the application with the Maven JVM this is fine.
It is just an alternative way to run your application instead of using the executable jar.
As an alternative you could also start your application with gradle
gradle bootRun
Which is best depends on your circumstance. For live production code I would use a versioned executable jar always.

Spring Boot and Continuous Delivery simple pipeline

I can't find any example or article how can the continuous delivery pipeline look like when we are using Spring Boot + Jenkins.
In Java EE I usually do it like this:
Push changes to repository
Jenkins checks for changes every 5 minutes
if there was a change, Jenkins pulls the sources and run maven build
using wildfly maven plugin I run redeploy on server
And generally I wonder what to do in last point when I'm using Spring Boot. Application is packaged into single JAR and run in separate process so in Spring Boot there is actually no such thing like redeploy. Do I have to write some script to kill old process first and then run the new artifact? Or maybe there is something like "spring boot cli" where I could manage all running spring boot apps?
You need to kill old process and run new process as a service.
It is all very well explained here Spring Boot application as a Service.
There is nice ssh plugin for jenkins that we use : https://wiki.jenkins-ci.org/display/JENKINS/Publish+Over+SSH+Plugin
Copy jar to the server
Stop old service
Run new service
EDIT : Added Spring boot reference for running spring boot as a service - http://docs.spring.io/spring-boot/docs/current/reference/html/deployment-install.html #Vaelyr

Resources