I'm upgrading my application to the new SpringBoot version. I'm actually in 2.3.5 using properties files like that : application-{profilename}.(properties/yaml)
I read those documentation : https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-Config-Data-Migration-Guide https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-Config-Data-Migration-Guide
My pom is this one :
I changed from
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-parent -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.projet.dev</groupId>
<artifactId>api</artifactId>
<version>3.0.0</version>
<name>api</name>
<description>ApiMain</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>11</java.version>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate.validator/hibernate-validator -->
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.el</artifactId>
<version>3.0.1-b12</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-mqtt</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.4.8</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>1.4.1.Final</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.10.8</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
In my application.properties :
spring.config.use-legacy-processing=true
In my application-local.properties :
# DATASOURCE (DataSourceAutoConfiguration & DataSourceProperties)
spring.main.banner-mode=off
# Hibernate ddl auto (create, create-drop, validate, update)
spring.jpa.hibernate.ddl-auto = update
# MANY OTHERS
When i start the app, it lauch without taking the properties !
I tried to apply spring.profiles.active=local
in my application.properties
but without success !
In vm argument i have this : -Dspring.profiles.active=local
With and without it just does not work..
I was not having any problem with 2.3.5.
spring.main.banner-mode=off
works
How i see that properties are not loaded :
I have spring.main.banner-mode=off
and the banner is displayed so something wrong.
Datasource properties are not loaded too..
Refer to : https://stackoverflow.com/questions/65008209/upgrade-springboot-2-3-5-to-2-4-0
Thanks for help, i'm sure it can help a lot of people !
For information in spring tool suite 4 4.5.0:
spring.config.use-legacy-processing=true
is an unknow property
Comment From: bclozel
Are there comments in your application.properties
file? This could be related to #24158
Comment From: snicoll
Indeed, you may confirm that quickly by running this app against 2.4.1-SNAPSHOT
.
Comment From: Whisper40
@bclozl Hi ! Thanks bro !! It was a shit bug ! 2.4.1-SNAPSHOT is actually not available in Maven :(
I close it because # was the problem !
Comment From: bclozel
@Whisper40 It's not on Maven Central as it's not a public release, but a SNAPSHOT version. You can add our snapshot repo to your build configuration. You can get the build snippet by generating a new Spring Boot project on https://start.spring.io/ and selecting 2.4.1-SNAPSHOT.
Comment From: Whisper40
@bclozel Thanks for the information :) I just tested with :: Spring Boot :: (v2.4.1-SNAPSHOT) The problem of " # " in properties is again present on my side ( yes i clean and then update project and release too) ( i have my lines with # )
Example :
#OpenAPI - Swagger UI
springdoc.swagger-ui.path=/swagger-ui.html
#Log
logging.level.org.hibernate.SQL=ERROR
logging.level.org.hibernate.type=ERROR
#TimeZone
spring.jpa.properties.hibernate.jdbc.time_zone = Europe/Paris
spring.jackson.time-zone: Europe/Paris
Comment From: bclozel
Can you create a small, sample application that reproduces the issue? Creating a small project on GitHub or uploading it here would be perfect. You can start from a fresh project on start.spring.io and add properties/specific things to your application until you can reproduce the issue.
Thanks!
Comment From: Whisper40
Just downloaded a default project and added properties. I run it with the same Vm argument -Dspring.profiles.active=local
I'm not having the problem with 2.4.1-SNAPSHOT with default project
But with mine yes, really strange, will try to investigate
Other thing : With default project and mine : https://prnt.sc/vqkwes
[Update] Working with 2.4.1-SNAPSHOT and # in properties with my project. I have got a problem of update project But the red thing in pom is always present -> Red thing does not appear with SpringToolSuite 4.5.0 -> Appears with 4.9.0
Comment From: snicoll
Thanks for the follow-up. We can't unfortunately provide you support with the error in your IDE. Please follow-up on StackOverflow for that.
Comment From: ivanetinajero
Hi everyone. I have the same problem. I updated Spring Boot from 2.3.6.RELEASE to 2.4.0 and it seems that application.properties is not loading. I have the following in application.properties:
empleosapp.ruta.imagenes=c:/empleos/img-vacantes/
After running, I got the error: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'vacantesController': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'empleosapp.ruta.imagenes' in value "${empleosapp.ruta.imagenes}"
Using 2.3.6.RELEASE it works fine
Thanks!
Comment From: bclozel
This doesn't seem to be related to this issue. Please create a new issue with a sample project reproducing the problem, as the current description doesn't provide enough information. Thanks