我想使用.properties
文件来使用Environment
和@PropertySources
读取mysql和hibernate属性,但我收到错误
java.io.FileNotFoundException:无法打开类路径资源[/com/properties/persistence/mysqldb.properties],因为它不存在
这是我的项目结构
PersistenceConfig.java
@Configuration
@EnableJpaRepositories(basePackages="com.hp.model.repository")
@EnableTransactionManagement
@PropertySources({
@PropertySource("classpath: /com/properties/persistence/mysqldb.properties"),
@PropertySource("classpath: /com/properties/persistence/hibernate.properties")})
public class PersistenceConfig {
@Autowired
Environment env;
.......
我已检查了我的构建路径,src/main/resources
位于类路径上,如下所示
任何线索我错过了什么?
答案 0 :(得分:1)
正如@Deinum指出你需要从classpath:com/properties/persistence/mysqldb.properties