Run class when starting web application

Asked

Viewed 319 times

0

I have a class that would need to run along with the web application every time it starts. I would upload the application to the server and this class would need to be run.

This application is running on Wildfly, and is also using Spring Framework.

In this class runs a Job, nothing more than programming a Scheduler to be executed at a fixed time of day. If there is another way to start (perhaps more correct) this process scheduling, it would certainly help me as well. It sounds like a simple question, but I swear I haven’t found a resolution.

1 answer

0


I can’t tell if you have a more accurate one because I don’t know your infra, but I would create a service with Jenkins to run at the scheduled time. Another alternative, as you have already designed, is to put this in an application start class but need to know what framework or type of project you are using.

  • I’ll take a look at Jenkins, see what I can do, thanks. I edited the question, to put the data you commented, is running with the Spring Framework. This start class you mentioned, how do I set up?

  • Check which of the two ways you are doing... https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/WebApplicationInitializer.html If it is code-based, where you have a class responsible for this "start", you can implement there.

  • I got a friend, thanks. This link that you shared helped me a little, I just saw an example where it started on the web.xml a "Listener" and directed a class to it.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.