我使用JPA创建了一个Spring Boot Dynamo数据库项目,就像this和另一个Spring Boot项目一样。
现在我正试图通过Maven在Dynamo数据库项目中加载JPA项目,如下所示:
<dependency>
<groupId>utils.br.com.xxx</groupId>
<artifactId>util-api</artifactId>
<version>0.0.1</version>
</dependency>
我收到了这个错误:
引起:java.lang.IllegalArgumentException:不是托管类型: class dynamo.br.com.xxx.model.Customer
我的主要类Dynamo DB项目
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
@SpringBootApplication
public class DynamoSpringBootWebApplication {
public static void main(String[] args) {
SpringApplication.run(DynamoSpringBootWebApplication.class, args);
}
}
JPA Project的application.properties的重要部分:
entitymanager.packagesToScan=utils.br.com.xxx.model
我的JPA数据库配置类:
@Configuration
@EnableTransactionManagement
public class DatabaseConfig {
@Value("${db.driver}")
private String DRIVER;
@Value("${db.password}")
private String PASSWORD;
@Value("${db.url}")
private String URL;
@Value("${db.username}")
private String USERNAME;
@Value("${entitymanager.packagesToScan}")
private String PACKAGES_TO_SCAN;
@Bean(name = "xxxDataSource")
public DataSource xxxDataSource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName(DRIVER);
dataSource.setUrl(URL);
dataSource.setUsername(USERNAME);
dataSource.setPassword(PASSWORD);
return dataSource;
}
@Bean(name = "xxxSessionFactory")
public LocalSessionFactoryBean analistaSessionFactory() {
LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean();
sessionFactory.setDataSource(gurgelDataSource());
sessionFactory.setPackagesToScan(PACKAGES_TO_SCAN);
Properties hibernateProperties = new Properties();
sessionFactory.setHibernateProperties(hibernateProperties);
return sessionFactory;
}
@Bean(name = "xxxTransactionManager")
public HibernateTransactionManager analistaTransactionManager() {
HibernateTransactionManager transactionManager = new HibernateTransactionManager();
transactionManager.setSessionFactory(analistaSessionFactory().getObject());
return transactionManager;
}
}
有关进展的任何想法?
谢谢!