Java dll auto=create时不存在错误关系

Java dll auto=create时不存在错误关系,java,spring,spring-boot,hibernate,Java,Spring,Spring Boot,Hibernate,我的实体类别: 包实体; 导入javax.persistence.*; 导入java.time.LocalDate; @实体 @NamedQuery(name=“selectAll”,query=“from Drug”) 公营药品{ @身份证 @GeneratedValue(策略=GenerationType.AUTO) 私有int-id; 私有字符串名称; 私人多头价格; 私有LocalDate mfd; 私有localdateexp; 公共药物(){ } 公共药品(字符串名称,长价格){ t

我的
实体
类别:

包实体;
导入javax.persistence.*;
导入java.time.LocalDate;
@实体
@NamedQuery(name=“selectAll”,query=“from Drug”)
公营药品{
@身份证
@GeneratedValue(策略=GenerationType.AUTO)
私有int-id;
私有字符串名称;
私人多头价格;
私有LocalDate mfd;
私有localdateexp;
公共药物(){
}
公共药品(字符串名称,长价格){
this.name=名称;
这个价格=价格;
}
公共字符串getName(){
返回名称;
}
公共void集合名(字符串名){
this.name=名称;
}
公共长期价格(){
退货价格;
}
公共定价(长期价格){
这个价格=价格;
}
public LocalDate getMfd(){
返回多功能显示器;
}
public void setMfd(本地制造日期){
此.mfd=制造的;
}
公共LocalDate getExp(){
返回经验;
}
public void setExp(LocalDate exp){
this.exp=exp;
}
公共int getId(){
返回id;
}
公共无效集合id(内部id){
this.id=id;
}
@凌驾
公共字符串toString(){
返回“毒品{”+
“id=”+id+
“,name=”“+name+”\“””+
“,price=“+价格+
“,mfd=“+mfd+
“,exp=“+exp+
'}';
}
}
我的
Config
class:

包配置;
导入org.hibernate.SessionFactory;
导入org.springframework.beans.factory.annotation.Autowired;
导入org.springframework.context.annotation.Bean;
导入org.springframework.context.annotation.ComponentScan;
导入org.springframework.context.annotation.Configuration;
导入org.springframework.jdbc.datasource.DataSourceTransactionManager;
导入org.springframework.jdbc.datasource.driverManager数据源;
导入org.springframework.orm.hibernate5.LocalSessionFactoryBean;
导入org.springframework.transaction.PlatformTransactionManager;
导入javax.sql.DataSource;
导入java.util.Properties;
@配置
@组件扫描({“服务”、“实体”、“dao”})
公共类配置{
@豆子
公共数据源数据源(){
DriverManager数据源dataSource=新的DriverManager数据源();
setDriverClassName(“org.postgresql.Driver”);
setUrl(“jdbc:postgresql://localhost:5432/");
dataSource.setUsername(“postgres”);
dataSource.setPassword(“123”);
返回数据源;
}
属性hibernateProperties(){
属性=新属性();
setProperty(“hibernate.ddl auto”、“create”);
properties.setProperty(“hibernate.dialent”、“org.hibernate.dialent.postgresql82dialent”);
setProperty(“hibernate.show_sql”,“false”);
setProperty(“spring.jpa.generateddl”、“true”);
setProperty(“spring.jpa.databaseplatform”、“postgres”);
归还财产;
}
@Bean(name=“sessionFactory”)
公共LocalSessionFactoryBean sessionFactory(){
LocalSessionFactoryBean sessionFactory=新的LocalSessionFactoryBean();
setDataSource(dataSource());
sessionFactory.setPackagesToScan(“实体”);
setHibernateProperties(hibernateProperties());
返回工厂;
}
@豆子
@自动连线
公共平台TransactionManager平台TransactionManager(SessionFactory SessionFactory){
返回新的DataSourceTransactionManager(dataSource());
}
}
我的申请:

包ir.training.ds;
导入config.config;
进口实体。毒品;
导入org.springframework.boot.SpringApplication;
导入org.springframework.boot.autoconfigure.springboot应用程序;
导入org.springframework.context.ApplicationContext;
导入org.springframework.context.annotation.AnnotationConfigApplicationContext;
进口服务;
导入java.time.LocalDate;
@SpringBoot应用程序
公共类DSA应用程序{
公共静态void main(字符串[]args){
run(DsApplication.class,args);
ApplicationContext ApplicationContext=新注释ConfigApplicationContext(Config.class);
DrugService DrugService=applicationContext.getBean(DrugService.class);
药物=新药(“aaa”,111l);
setMfd(LocalDate.now());
(2022,01,02)的本地日期;
药物服务。添加(药物);
}
}
在XML配置中,一切都运行良好;但是在注释配置中,我有这个错误!我犯了什么错

在annotation config中,如果药物表已经存在,我的应用程序可以正常工作,但它无法创建表本身

我无法找到问题。

而不是:

properties.setProperty("hibernate.ddl-auto", "create");
使用:


现在可以了。谢谢你的帮助。
properties.setProperty("hibernate.ddl-auto", "create");
properties.setProperty("hibernate.hbm2ddl.auto", "update");