Home > Back-end >  Spring not detecting application.properties
Spring not detecting application.properties

Time:10-31

Spring is not detecting my application.properties in the config folder. The config file: (Sensitive Information hidden)

server.port = 8090
spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:mysql://${MYSQL_HOST:URL}:3306/DB
spring.datasource.username=USER
spring.datasource.password=PW
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
debug=true

Folder structure:

https://img.codepudding.com/202210/9706fcf7733343bb8254819a81568ce4.png

Server.java

@SpringBootApplication
@EnableAutoConfiguration
public class Server {
    public static void main(String[] args) {
        SpringApplication application = new SpringApplication(Server.class);
        application.run();
    }
}

I tried putting the properties in he top and resources folder, nothing seems to work. If I try to load it via VM options it says resource not found. The config folder is marked as resource folder in IntelliJ

CodePudding user response:

application.properties file should be located in the resource directory.

CodePudding user response:

I think I figured the problem out, the folders are fine, I configured the wrong home directories for each main. It would have been better to make two different projects. Example: Old home directory: /home/.../github/AzChat/src/de/united/azchat/ Now: /home/.../github/AzChat/src/de/united/azchat/server/ Folder Structure now:Folder Structure

  • Related