Autowiring fails: Not an managed Type

前端 未结 13 2110
清酒与你
清酒与你 2020-12-02 12:30

I have a big problem in my diploma project and would be very glad if you guys could help me! I made a Maven Multi Module Project and have 3 \"Core-projects\"

  • <
13条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-02 12:50

    After encountering this issue and tried different method of adding the entity packaname name to EntityScan, ComponentScan etc, none of it worked.

    Added the package to packageScan config in the EntityManagerFactory of the repository config. The below code gives the code based configuration as opposed to XML based ones answered above.

    @Primary
    @Bean(name = "entityManagerFactory")
    public EntityManagerFactory entityManagerFactory() {
        LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
        emf.setDataSource(dataSource);
        emf.setJpaVendorAdapter(jpaVendorAdapter);
        emf.setPackagesToScan("org.package.entity");
        emf.setPersistenceUnitName("default"); 
        emf.afterPropertiesSet();
        return emf.getObject();
    }
    

提交回复
热议问题