Spring boot - Not a managed type
Solution 1:
Configure the location of entities using @EntityScan in Spring Boot entry point class.
Update on Sept 2016: For Spring Boot 1.4+:
use org.springframework.boot.autoconfigure.domain.EntityScan
instead of org.springframework.boot.orm.jpa.EntityScan
, as ...boot.orm.jpa.EntityScan is deprecated as of Spring Boot 1.4
Solution 2:
Try adding All the following, In my application it is working fine with tomcat
@EnableJpaRepositories("my.package.base.*")
@ComponentScan(basePackages = { "my.package.base.*" })
@EntityScan("my.package.base.*")
I am using spring boot, and when i am using embedded tomcat it was working fine with out @EntityScan("my.package.base.*")
but when I tried to deploy the app to an external tomcat I got not a managed type
error for my entity.
Extra read:
@ComponentScan
is used for scanning all your components those are marked as @Controller, @Service, @Repository, @Component
etc…
where as @EntityScan
is used to scan all your Entities those are marked @Entity
for any configured JPA in your application.
Solution 3:
I think replacing @ComponentScan
with @ComponentScan("com.nervy.dialer.domain")
will work.
Edit :
I have added a sample application to demonstrate how to set up a pooled datasource connection with BoneCP.
The application has the same structure with yours. I hope this will help you to resolve your configuration problems
Solution 4:
If you configure your own EntityManagerFactory Bean or if you have copy-pasted such a persistence configuration from another project, you must set or adapt the package in EntityManagerFactory's configuration:
@Bean
public EntityManagerFactory entityManagerFactory() throws PropertyVetoException {
HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
vendorAdapter.setGenerateDdl(true);
LocalContainerEntityManagerFactoryBean factory;
factory = new LocalContainerEntityManagerFactoryBean();
factory.setPackagesToScan("!!!!!!package.path.to.entities!!!!!");
//...
}
Be careful of the "multiple" needs, you need a String array as the argument passed to setPackagesToScan (and NOT a comma-separated-single-string value). Below illustrates the issue.
String[] packagesArray = "com.mypackage1,com.mypackage2".split(",");
em.setPackagesToScan(packagesArray);