For some reason, the method is performed twice in all ways!
Prompt other ways to automatically execute the method when the program starts. Or if anyone knows, tell me what could be the problem of double launch of the method?
Option 1:
@Service public class RunJob implements InitializingBean { public void afterPropertiesSet() { System.out.println("JOB RUN"); } } Option 2:
public class RunJob { @PostConstruct public void initRun() { System.out.println("JOB RUN"); } } Option 3:
mvc-servlet.xml :
<bean id="runJobBean" class="com.java.myproject.util.RunJob" init-method="init"></bean> public class RunJob { @Override public void init() { System.out.println("JOB RUN"); } }