记一次关于JPA2.1扫描包注解配置和代码配置搞混的混账事情

记录此次失败的错误,一警告自己以后做事情一定要仔细,通读全篇再开工!!!!


//启动时注入全局参数
@Configuration
//指定服务包
//@ComponentScan(basePackages = {"com.yt.design"})
@EnableJpaRepositories(basePackages = "com.yt.design.jpa.repository")
@EntityScan(basePackages = {"com.yt.design.jpa.entity"})
//指定启动事务管理
@EnableTransactionManagement
public class JPAConfig {
      。。。。。。
}
 @Bean(name = "entityManagerFactory")
    public LocalContainerEntityManagerFactoryBean entityManagerFactory
            (DataSource dataSource) {
        LocalContainerEntityManagerFactoryBean em = new
                LocalContainerEntityManagerFactoryBean();
        em.setDataSource(dataSource);
//        TODO;2018年04月12日20:22:57教训仔细啊
        em.setPackagesToScan("com.yt.design.jpa.entity");

        JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
        em.setJpaVendorAdapter(vendorAdapter);
        em.setJpaProperties(additionalProperties());

        return em;
    }

你可能感兴趣的:(记一次关于JPA2.1扫描包注解配置和代码配置搞混的混账事情)