【发布时间】:2019-09-05 08:05:50
【问题描述】:
我正在创建一个 Spring Boot Batch 应用程序。该批次从 postgres 加载数据并插入 MongoDB。我已经编写了代码,但是在运行 spring boot 应用程序时,它显示错误 application.properties 文件未找到。以下是错误sn-ps:
'Caused by: java.io.FileNotFoundException: class path resource [application.properties] cannot be opened because it does not exist'
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.example.batch.SpringBatchExample]; nested exception is java.io.FileNotFoundException: class path resource [application.properties] cannot be opened because it does not exist
下面是application.properties文件内容:
spring.data.mongodb.host=localhost
spring.data.mongodb.port=27017
spring.data.mongodb.database=Test_Data
#logging
logging.level.org.springframework.data=DEBUG
logging.level.=ERROR
logging.level.com.mastercard.refdata.*=DEBUG
#By default, Spring runs all the job as soon as it has started its context.
spring.batch.job.enabled=false
#Chunk Size to save data
spring.chunk.size=200
#Postgres DATASOURCE
spring.datasource.url=jdbc:postgresql://localhost:5432/Company-Test
spring.datasource.username=postgres
spring.datasource.password=test123
spring.datasource.driver-class-name=org.postgresql.Driver
请告诉我为什么会遇到这个问题??
【问题讨论】:
-
请张贴您编写的代码,或一个最小的、可验证的代码示例。另外,请格式化您的问题,使其更具可读性。
-
确保
application.properties文件在您的类路径中。如果你使用maven,应该在src/main/resources目录下。 -
发布你的项目结构截图。
标签: spring spring-boot spring-batch