question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@EntityScan value attribute not evaluated anymore

See original GitHub issue

Hello,

When upgrading to Spring Boot 1.4.0.RC1 from MS3, the value attribute of the org.springframework.boot.autoconfigure.domain.EntityScan annotation is not evaluated as expected.

This results in an exception:

@Configuration
@EntityScan(value = "my.base.entity.package")
public class PersistenceConfiguration {
  //...
}

However, this works:

@Configuration
@EntityScan(basePackages = "my.base.entity.package")
public class PersistenceConfiguration {
  //...
}

Exception cause is:

Caused by: java.lang.IllegalArgumentException: Not a managed type: class my.base.entity.package.MyEntity
    at org.hibernate.jpa.internal.metamodel.MetamodelImpl.managedType(MetamodelImpl.java:210) ~[hibernate-entitymanager-5.0.9.Final.jar:5.0.9.Final]
    at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation.<init>(JpaMetamodelEntityInformation.java:68) ~[spring-data-jpa-1.10.2.RELEASE.jar:na]
    at org.springframework.data.jpa.repository.support.JpaEntityInformationSupport.getEntityInformation(JpaEntityInformationSupport.java:67) ~[spring-data-jpa-1.10.2.RELEASE.jar:na]
    at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getEntityInformation(JpaRepositoryFactory.java:152) ~[spring-data-jpa-1.10.2.RELEASE.jar:na]
    at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:99) ~[spring-data-jpa-1.10.2.RELEASE.jar:na]
    at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:81) ~[spring-data-jpa-1.10.2.RELEASE.jar:na]

From a quick debugging session, it seems to me that the evaluation of the value attribute is missing in org.springframework.boot.autoconfigure.domain.EntityScanPackages.Registrar#getPackagesToScan

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:15 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
gbauercommented, Jul 7, 2016

@snicoll Thanks for fixing this so quick. I’ll test it on Monday on the real-world project.

0reactions
bojan-milojkoviccommented, Apr 12, 2019

If you copy-pasted persistence configuration from another project, you must set the entity scan in EntityManagerFactory manually :

@Bean
public EntityManagerFactory entityManagerFactory() throws PropertyVetoException {
    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setPackagesToScan("**misspelled.package.path.to.entities**");
    .....
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

SpringBootApplication and @ComponentScan not working ...
Spring Boot will scan all the packages and sub packages starting with the package that the @SpringBootApplication annotated class is in.
Read more >
spring-projects/spring-boot - Gitter
Now when adding an @EntityScan("org.bar.entities") on that class the entities in org.foo.entities aren't detected anymore. This was a bit of a surprise.
Read more >
EntityScan (Spring Boot 3.0.0 API)
Base packages to scan for entities. value() is an alias for (and mutually exclusive with) this attribute. Use basePackageClasses() for a type-safe alternative ......
Read more >
Is Spring-Boot (still) not working with JSR310Converters for ...
In order to have the database (I am using H2) contain TIMESTAMP-type columns with values rather than VARBINARY-type columns with values one cannot...
Read more >
Required identifier property not found for class c... - Neo4j
Of course you can also use other versions but this is the version, Spring Boot was tested with. As long as Spring Data...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found