Reputation: 16147
I'm extending the capabilities of our application. Right now, We only certain classes on our app that's going to be used by our web platform, Is it possibile in spring boot to specify specific hibernate classes instead of doing a complete package scan for those classes?
Instead of something like this
@EntityScan(basePackages =
{"org.app.app.domain",
"org.jar.jar.domain.process"
});
I was thinking of something
@Scan(classes ="org.mypackage.package.ClassA,org.mypackage2.package.ClassB")
is that something like that exists?
Upvotes: 2
Views: 398
Reputation: 56
Assuming that you are using JPA:
You can omit @EntityScan in favor of @EnableJpaRepositories. By doing so, the EntityManager will automatically pick up any Entities registered via their associated repositories, while allowing you to use all the usual @ComponentScan tricks.
Below is just an example, that illustrates a component scan filter that will grab anything ending in "JpaRepository".
@Configuration
@EnableJpaRepositories(includeFilters = {
@ComponentScan.Filter(type = FilterType.REGEX, pattern = {".*JpaRepository"})
})
public class SomeAppConfig {
}
Upvotes: 2