[英]Not able to inject .properties file into Spring MVC 4.3 using @PropertySource
我想使用.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
在classpath上,如下所示
任何線索我想念什么?
正如@Deinum指出的那樣,您需要從classpath:com/properties/persistence/mysqldb.properties
刪除空格。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.