Spring Boot初始化不从hibernate.properties读取

时间:2019-04-06 05:16:23

标签: spring hibernate spring-boot

我正在尝试使用Spring Boot,Hibernate和mysql创建一个非常基本的Spring Boot Web应用程序。基本目标是将复杂的json转换为pojos的级联集并保留在db中。在hibernate.properties中,我配置了Mysql5InnodbDialect,但初始化使用其他方言。希望下面的日志足以解释,不过,如果需要更多信息,可以发布。

2019-04-06 10:25:36.448信息2256 --- [main] org.hibernate.Version:HHH000412:Hibernate Core {5.3.7.Final}

2019-04-06 10:25:36.448信息2256 --- [main] org.hibernate.cfg.Environment:HHH000205:从资源hibernate.properties中加载的属性:{hibernate.dialect = org.hibernate.dialect。 MySQLInnoDBDialect,hibernate.show_sql = true,hibernate.bytecode.use_reflection_optimizer = false,hibernate.hbm2ddl.auto = UPDATE,hibernate.format_sql = true}

2019-04-06 10:25:36.511信息2256 --- [main] o.hibernate.annotations.common.Version:HCANN000001:Hibernate Commons注释{5.0.4.Final}

2019-04-06 10:25:36.573信息2256 --- [main] org.hibernate.dialect.Dialect:HHH000400:使用方言:org.hibernate.dialect.MySQL5Dialect

1 个答案:

答案 0 :(得分:0)

您可以尝试在Spring Boot中扫描应用程序属性文件吗?

@EnableAutoConfiguration
@SpringBootApplication(scanBasePackages={"com.virus.shopingcart.*"})
@EnableJpaRepositories("com.virus.shopingcart.*")
@ComponentScan("com.virus.shopingcart.*")
@PropertySource("classpath:application.properties")
public class ShopingBoot extends SpringBootServletInitializer {

public static void main(String[] args) {

        SpringApplication.run(ShopingBoot.class, args);
}

}