How to library Spring Boot applications

Asked 2 years ago, Updated 2 years ago, 96 views

I was creating a command line application on Spring Boot, but suddenly I had to use a library instead of an app.

Development Environment: Eclipse, Windows 7 Development Language: Java framework:Spring Boot

以下 Below, xxxxx.jar is what I created.

Current Boot Method

How to Boot After Changes

Would it be possible to migrate like this while taking advantage of the functionality of the Spring framework?
Currently, I have deleted the main method of the main class, created the execute method, and registered it in an existing application, but it has not started well with the following error:

Failed to process import candidates for configuration class [xxx.xxx.MainClass]; nested exception is java.lang.IllegalArgumentException: No auto configuration classes found in META-INF/spring.factories.If you are using a custom, causing damage.creating

There is a lot of information to create an application using the framework, but is there any way to create a library (without the main method) using the framework)?
Can't you do that in general?

After trial and error, the above error disappeared.
However, the Autowired annotation does not DI.

java windows eclipse spring-boot

2022-09-30 15:38

1 Answers

The class that was not DIed in Autowired was an instance new from the caller.
Therefore, when I tried to create an instance of the desired class using ApplicatoinContext#getBean() in the class that wrapped the class, it was DIed.


2022-09-30 15:38

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.