spring boot 3 upgrade: error in application.yml file - spring

I have upgraded spring boot version to 3 and getting below error for the field connection-timeout in properties file, what alternative can I use for this?
Property source 'Config resource 'class path resource [application.yml]' via location 'optional:classpath:/'':
Key: server.connection-timeout
Line: 16
Reason: Each server behaves differently.
Please refer to the release notes or reference guide for potential alternatives.

There is an answer: https://stackoverflow.com/a/72700025/345130
In short, server.connection-timeout was removed in Spring Boot 2.3.0.RELEASE.
User server-specific properties, such as server.tomcat.connection-timeout.

Related

Spring Migration from 4.x to 5.3.19

I have migrated all libraries for Spring4.x and hibernate3.x to Hibernate 5 and spring 5.3.19. I have below line of code in my configuration file
bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/> with this it's throwing error class not found. I understood it's deprecated in latest spring. But what is the alternative for this in latest spring version.
After commenting the above line in my configuration file, Server is started successfully But when I hit URL I am getting below error.
HTTP Status 404 – Not Found
Type Status Report
Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
Apache Tomcat/9.0.43.

Spring Boot 2 - YAML keys with special characters

I am upgrading my application from SpringBoot 1.5 to 2.3, the old application had the following yml file
config:
pic_code:
"Test/Try": "ABC"
"Trial": "DRF"
After upgrading, YAML key with '/' is not being read properly and gives null.
I have tried to change the key as below
"[Test/Try]"
'[Test/Try]'
"Test'/Try"
but nothing worked.
Any suggestions will be very much helpful
It works with '[Test/Try]' as per the link shared above Spring Boot YAML configuration with URL in key no longer loads correctly with version 2

Consider defining a bean of type 'org.springframework.social.twitter.api.Twitter' in your configuration

So I am following https://spring.io/guides/gs/accessing-twitter/ to connect my application to Twitter to get some user data. But it looks like with recent changes to Spring boot (version 2.0.3.RELEASE) and Spring-social-twitter, I am not able to execute the said article successfully. I keep getting following error:
Consider defining a bean of type 'org.springframework.social.twitter.api.Twitter' in your configuration.
Has anyone tried the same sample with new Spring boot release? What am I missing?

What changed about loading Spring Resource file from classpath in Spring Boot in v1.5.12?

Prior to Spring Boot v1.5.11, the following worked for referring to a file called auth.json in src/main/resources:
spring.cloud.gcp.credentials.location=auth.json
Starting with v1.5.11 and continuing through into 1.5.12, the above results in a FileNotFound exception. But the following works:
spring.cloud.gcp.credentials.location=classpath:auth.json
What changed in Spring Boot 1.5.12 (or its underlying dependencies) that was responsible for this?
This was caused by a fix to another issue and is being tracked via another reported instance here: https://github.com/spring-projects/spring-boot/issues/12786
Practitioners hitting this behavior may either update their implementation in an appropriate way (e.g., in our sanitized sample, it would be to prefix the property with "classpath:") or to wait to see if further resolution (that doesn't regress the other fix that caused this) is possible.
h/t #Stephane-Nicoll and Andy Wilkinson.

Spring Cloud Client Config with placeholders

I have a Spring Boot application.yml with this config for Cloud Config:
spring:
cloud:
config:
uri: http://localhost:8080/config
name: ${cluster.name}
profile: ${cluster.idx}
I read cluster.name and cluster.idx from a custom PropertySouce that loads a JSON file. But Spring Boot is not capable of resolve the placeholder yet.
13:04:37,370 ERROR [main] org.springframework.boot.SpringApplication(SpringApplication.java:839) : Application startup failed
java.lang.IllegalArgumentException: Could not resolve placeholder 'cluster.idx' in string value "${cluster.idx}"
How do I tell Spring Boot to load my PropertySource before trying to resolve the placeholders? Thanks in advance.
I'm using Sp Boot 1.4.3 and Sp Cloud Config 1.2.2.
You won't be able to use the property sources as they are not yet available, and will not be at the time that this file is read. You have a couple of options, though. First, you can place these properties into the bootstrap.properties (or bootstrap.yml if you prefer). I suspect that you are trying to do something that's profile driven though and should use the appropriate properties for the profile. In this case, you can create bootstrap-{profile}.yml. So, if you are running with -Dspring.profiles.active=dev, you would have a bootstrap-dev.yml file that would contain the values for this profile.
The second and simpler approach would be to pass these to the VM as arguments. -Dcluster.name=foo -Dcluster.idx=bar

Resources