Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

content of application.properties not processed after upgrading to Spring Boot 2.4.0 #24263

Closed
Whisper40 opened this issue Nov 26, 2020 · 10 comments
Labels
status: invalid An issue that we don't feel is valid

Comments

@Whisper40
Copy link

Whisper40 commented Nov 26, 2020

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 2.3.5.RELEASE to 2.4.0
I updated the project in eclipse

<?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

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 26, 2020
@bclozel
Copy link
Member

bclozel commented Nov 26, 2020

Are there comments in your application.properties file? This could be related to #24158

@bclozel bclozel added the status: waiting-for-feedback We need additional information before we can continue label Nov 26, 2020
@snicoll
Copy link
Member

snicoll commented Nov 26, 2020

Indeed, you may confirm that quickly by running this app against 2.4.1-SNAPSHOT.

@snicoll snicoll changed the title Upgrade from 2.3.5 To 2.4.0 content of application.properties not processed after upgrading to Spring Boot 2.4.0 Nov 26, 2020
@Whisper40
Copy link
Author

Whisper40 commented Nov 26, 2020

@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 !

@bclozel
Copy link
Member

bclozel commented Nov 26, 2020

@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.

@Whisper40
Copy link
Author

Whisper40 commented Nov 26, 2020

@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

@Whisper40 Whisper40 reopened this Nov 26, 2020
@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Nov 26, 2020
@bclozel
Copy link
Member

bclozel commented Nov 26, 2020

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!

@bclozel bclozel added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels Nov 26, 2020
@Whisper40
Copy link
Author

Whisper40 commented Nov 26, 2020

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

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Nov 26, 2020
@bclozel bclozel added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels Nov 26, 2020
@snicoll
Copy link
Member

snicoll commented Nov 27, 2020

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.

@snicoll snicoll closed this as completed Nov 27, 2020
@snicoll snicoll added status: invalid An issue that we don't feel is valid and removed status: waiting-for-feedback We need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged labels Nov 27, 2020
@ivanetinajero
Copy link

ivanetinajero commented Dec 5, 2020

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!

@bclozel
Copy link
Member

bclozel commented Dec 5, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

5 participants