Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/351.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 为什么Spring找不到这个hibernate.properties文件?_Java_Spring_Hibernate_Intellij Idea - Fatal编程技术网

Java 为什么Spring找不到这个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

我在src/main/resources中有一个hibernate.properties文件,还有这个类

@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文件的情况下错误地找到路径。谢谢你的建议。不幸的是,正斜杠没有什么区别。