currently I am trying to add spring boot to an existing project.
This project is a standalone jar that successfully uses spring jpa and hibernate. But because the application must be able to receive and send json files, I thought that spring boot would be the best option.
Therefore I added the following dependency to my pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>1.4.0.RELEASE</version>
</dependency>
And set up a little RequestMapping as a test
@Controller
public class RequestMappingController {
@RequestMapping("/")
@ResponseBody
public String myAction() {
return "Hello World !";
}
}
Now I have the problem, that all my sources (this, this and this) are telling me to set up the main method next.
Something like
public static void main(String[] args) {
SpringApplication.run(Main.class, args);
}
But I am not able to change that method. My architecture uses a main jar file that loads components and plugins as jar files. And the main jar file is downloaded and is not programmed by me.
main.jar (downloaded)
|- plugin1.jar (programmed by me)
|- plugin2.jar (programmed by me)
|- ...
I am not using any xml files (except the pom.xml file of course) to configure spring. In my
plugin1.jarthere is a JpaConfig Class with all the important spring enabling annotations (
@EnableScheduling,
@EnableAsync, transactionmanagement, component scan,
@Configuration, jpa repository enabling, ...)
@SpringBootConfiguration` and because my plugin1 is able to activate all current implemented spring components in this Configuration class, maybe I can set up spring boot there as well? (is there a way? or some other way with a second configuration class?)
I recognices that there is also a annotation
And that is my question: how can I enable spring boot within this existing project structure without changing the main(String[] args)
method?