Reputation: 300
I have simple spring application.
Spring
version is 3.2.16.RELEASE
.
Project structure is:
Application class looks like:
@Configuration
@ComponentScan(basePackages = "ua.xxxx.spring.hometask")
@PropertySource(value = "classpath:application.properties")
public class Application {
public static void main(final String[] args) {
final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Application.class);
final SpringHomeTaskConsoleUI consoleUI = context.getBean(SpringHomeTaskConsoleUI.class);
consoleUI.run();
}
}
When I try to run it I have:
Caused by: java.io.FileNotFoundException: class path resource [application.properties] cannot be opened because it does not exist
I have trying:
@PropertySource(value = "classpath*:application.properties")
@PropertySource(value = "classpath:/application.properties")
@PropertySource(value = "classpath:src/main/resources/application.properties")
@PropertySource(value = "classpath*:src/main/application.properties")
@PropertySource(value = "classpath:application.properties")
@PropertySource(value = "application.properties")
@PropertySource(value = "src/main/application.properties")
and other...
Resources folder is marked as resource root... Intellij project structure is ok.
Any ideas what can be wrong? Did I missed something?
Thanks in advice!
Upvotes: 1
Views: 6223
Reputation: 11
Please try to add org.springframework.boot spring-boot-configuration-processor
.
Upvotes: 1
Reputation: 112
Try to add absolute path file location @PropertySource("file:/root/.../application.properties")
Upvotes: 1