I've a package (say packagesToScan
) containing Classes that I wish to persist annotated with @Entity
.
While defining ApplicationContext
configuration, I've done as follows.
@Configuration
@EnableJpaRepositories("packagesToScan")
@EnableTransactionManagement
@PropertySource("server/jdbc.properties")
@ComponentScan("packagesToScan")
public class JpaContext {
...
// Other configurations
....
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
emf.setDataSource(this.dataSource());
emf.setJpaVendorAdapter(this.jpaVendorAdapter());
emf.setPackagesToScan("packagesToScan");
emf.setJpaProperties(this.hibernateProperties());
return emf;
}
While developing, I've some classes within packagesToScan
which doesn't satisfy requirements for persistence (like no primary keys etc) and due to this I'm not allowed to run test because of ApplicationContext
setup failure.
Now,
Is there any way that I can scan just some selected classes or ignore some classes within packagesToScan
?
packagestoscan
?