Java 为什么Spring找不到这个hibernate.properties文件?
我在src/main/resources中有一个hibernate.properties文件,还有这个类Java 为什么Spring找不到这个hibernate.properties文件?,java,spring,hibernate,intellij-idea,Java,Spring,Hibernate,Intellij Idea,我在src/main/resources中有一个hibernate.properties文件,还有这个类 @Configuration @PropertySource("classpath:hibernate.properties") public class PropertyConfig { @Bean public static PropertyPlaceholderConfigurer getProperties() { return new Proper
@Configuration
@PropertySource("classpath:hibernate.properties")
public class PropertyConfig {
@Bean
public static PropertyPlaceholderConfigurer getProperties() {
return new PropertyPlaceholderConfigurer();
}
}
…但是,当我启动我的web应用程序vai Intellij时,我遇到了以下例外情况:
无法解析中的占位符“hibernate.connection.driver\u class”
字符串值${hibernate.connection.driver\u class}
我会做错什么?!这看起来应该很简单。尝试在类路径之后添加斜杠:,所以
@PropertySource("classpath:/hibernate.properties")
有时Spring可能会在没有发布hibernate.properties文件的情况下错误地找到路径。谢谢你的建议。不幸的是,正斜杠没有什么区别。