[英]Not able to inject .properties file into Spring MVC 4.3 using @PropertySource
I want to use .properties
file to read mysql and hibernate properties using Environment
and @PropertySources
but I am getting error below 我想使用
.properties
文件使用Environment
和@PropertySources
读取mysql和hibernate属性,但是下面出现错误
java.io.FileNotFoundException: class path resource [ /com/properties/persistence/mysqldb.properties] cannot be opened because it does not exist
java.io.FileNotFoundException:类路径资源[/com/properties/persistence/mysqldb.properties]无法打开,因为它不存在
Here is my project strutucture 这是我的项目结构
PersistenceConfig.java 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;
.......
I have checked my build path and src/main/resources
is on the classpath as shown below 我已经检查了我的构建路径,并且
src/main/resources
在classpath上,如下所示
Any clue what I am missing ? 任何线索我想念什么?
正如@Deinum指出的那样,您需要从classpath:com/properties/persistence/mysqldb.properties
删除空格。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.