As guided by the thread\'s name, I would like to create a JAVA library by using Spring Boot. I have found this thread: Creating a library jar using Spring boot. However, that th
When designed in the correct way this should not be a problem at all. But in detail it depends which features you're using. Since Spring supports external library like JPA, Websocket,..
There are two important annotations to develop a library and use it in another project.
The first one is simply @Configuration
and the other one is @Import
.
Library Project
Put a class in the root package which looks something like this.
@Configuration // allows to import this class
@ComponentScan // Scan for beans and other configuration classes
public class SomeLibrary {
// no main needed here
}
Other Project using the library
As usually put a class in the root package of your project.
@SpringBootApplication
@Import(SomeLibrary.class) // import the library
public class OtherApplication {
// just put your standard main in this class
}
It is important to keep in mind, that other things might be necessary depending on what your using in terms of other frameworks.
For example if your using spring-data the @EntityScan
annotation extends the hibernate scan.