after upgrade spring-boot:2.3.11.RELEASE to spring-boot:2.5.5 and spring-cloud:Hoxton.SR11 to spring-cloud:2020.0.4, spring-boot:run is failing with:
***************************
APPLICATION FAILED TO START
***************************
Description:
No spring.config.import property has been defined
Action:
Add a spring.config.import=configserver: property to your configuration.
If configuration is not required add spring.config.import=optional:configserver: instead.
To disable this check, set spring.cloud.config.enabled=false or
spring.cloud.config.import-check.enabled=false.
Advices are pretty clear so I added
spring.cloud.config.enabled=false
spring.cloud.config.import-check.enabled=false
spring.config.import=optional:configserver:
to both application.properties and bootstrap.properties files
In application.properties I had to comment out line spring.config.import=optional:configserver: otherwise it failed with java.lang.IllegalStateException: Unable to load config data from 'optional:configserver:' ......... Caused by: java.lang.IllegalStateException: File extension is not known to any PropertySourceLoader
As I didn't need to comment it out in bootstrap.properties, values are ignored completely there probably
However application itself failed the same way as without any new properties added.
Any ideas what is the problem? What is correct format for spring.config.import=... ?
EDIT:
after adding dependency
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
it doesn't ignore properties in bootstrap.properties anymore so I had to comment out "spring.config.import=optional:configserver:" there as well. However application still failing with "No spring.config.import property has been defined"
In Spring Cloud 2020 you dont need bootstrap.properties anymore, importing spring-cloud-starter-bootstrap enable only a legacy way to use it.
Just remove it...
You need to add
spring.config.import=optional:configserver:http://your.config.server.com
into your application.properties. Howerver I not sure what you try to achieve, because of your
spring.cloud.config.enabled=false
More Info
Related
I got latest Spring Boot app and springdoc.swagger-ui on board.
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.2.32</version>
</dependency>
My application.properties contains springdoc.swagger-ui.path=/swagger-ui-openapi.html
When I run application via Intellij IDEA http://localhost:8080/swagger-ui-openapi.html brings me to http://localhost:8080/swagger-ui/index.html?configUrl=/v3/api-docs/swagger-config
and Swagger UI page loads successfully.
But if I start the app via command line: "java -jar my-app.jar", I got 404 in browser and Error in logs 'Circular view path [error]' when trying to reach http://localhost:8080/swagger-ui-openapi.html
and it redirrects me to http://localhost:8080/swagger-ui/index.html?configUrl=/v3/api-docs/swagger-config
javax.servlet.ServletException: Circular view path [error]: would dispatch back to the current handler URL [/error] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)
However http://localhost:8080/v3/api-docs is reachable and schema is available at this address.
How can I fix this?
What worked in my case when your application is running behind a proxy, a load-balancer or in the cloud.
In your Spring Boot application make sure your application handles this header: X-Forwarded-For.
There are two ways to achieve this:
In your properties file add:
server.use-forward-headers=true
If this is not enough, Spring Framework provides a ForwardedHeaderFilter. You can register it as a Servlet Filter in your application by setting server.forward-headers-strategy is set to FRAMEWORK.
Since Spring Boot 2.2, this is the new property to handle reverse proxy headers:
In your properties file add
server.forward-headers-strategy=framework
And you can add the following bean to your application:
#Bean
ForwardedHeaderFilter forwardedHeaderFilter() {
return new ForwardedHeaderFilter();
}
If you already have static content on your root, and you don’t want it to be overridden by springdoc-openapi-ui configuration, you can just define a custom configuration of the swagger-ui, in order not to override the configuration of your files from in your context-root:
For example use in your properties file:
springdoc.swagger-ui.path= /swagger-ui/api-docs.html
ref:
https://springdoc.org/
For this problem, my conclusion is:
(1) Starting it in IDEA is fine
(2) Repackaging the jar with spring-boot-maven-plugin and starting it with 'java -jar' is fine as well.
(3) if I tried to starting with such as 'java -classpath ".:.conf" DemoApplication', it does not work.
So, for packaging, i use the spring-boot-maven-plugin.
You don't need swagger-annotations v1.6.1 dependency for springdoc-openapi;
By default, with springdoc you need no additonal settings of any ViewResolver.
You can have a look at some sample code:
https://github.com/springdoc/springdoc-openapi-demos
I programaticaly configured my DataSource and I'm encountering an error saying:
dataSource or dataSourceClassName or jdbcUrl is required.
I managed to make it work by just changing spring.datasource.url in my .properties file.
Having errors: spring.datasource.url
No errors: spring.datasource.jdbc-url
What I don't know is how does it make it work by just specifying jdbc-url instead of url?
This is how the properties are defined in my project:
spring.datasource.url=jdbc:mysql://localhost:3306/mySchema
spring.datasource.username=theUserName
spring.datasource.password=123456
I am trying to run gradlew flywayMigrate, and the application chrashes when running a recurring migration with the error
Caused by: org.flywaydb.core.api.FlywayException: No value provided for placeholder expressions: ${dbLinkHost}, ${dbLinkPassword}, ${dbLinkSid}, ${dbLinkUser}. Check your configuration!
The variables are configured like this in application.yml:
flyway:
placeholders:
dbLinkHost: ...
dbLinkSid: ...
dbLinkUser: ...
dbLinkPassword: ...
And I try to access them like this in the sql file:
'${dbLinkHost}'
Does anyone know why the declarations in application.yml don`t seem to be accessible here?
As a result of Spring Boot Issue #9896 - Move Flyway configuration properties to spring.flyway and commit f9e3163, starting with v2.0.0.M4, Flyway configuration properties in your application properties start with spring.flyway. To configure Flyway placeholders, for example:
spring:
flyway:
placeholders:
dbLinkHost: ...
dbLinkSid: ...
dbLinkUser: ...
dbLinkPassword: ...
In Spring Boot versions before v2.0.0.M4 such as the recently-released v1.5.14.RELEASE, Flyway configuration properties start with flyway.
I have got an error with creating webservice from wsdl.
I have already configred a maven plugin
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
for creation of java classes.
In my wsdl I have got reference to swaref.xsd
<xs:import namespace="http://ws-i.org/profiles/basic/1.1/xsd" schemaLocation="swaref.xsd"/>
When I launch springBoot app, I have got the following error:
Have you got any idea what's wrong? Maybe with apache cxf ?
Check if swaref.xsd exists along with the wsdl-file in the same location
Check if swaref.xsd contains the same namespace http://ws-i.org/profiles/basic/1.1/xsd, as referenced in wsdl-file
Check if swaref.xsd is a valid xml, then is a valid schema file.
While deploying application on weblogic 11g I get following error.
java.lang.NoSuchMethodError: org/springframework/beans/MutablePropertyValues.add(Ljava/lang/String;Ljava/lang/Object;)Lorg/springframework/beans/MutablePropertyValues;
I have following spring jars in my application
com.springsource.org.aopalliance-1.0.0.jar
com.springsource.org.aopalliance-sources-1.0.0.jar
org.springframework.beans-3.2.1.RELEASE.jar
org.springframework.context-3.2.1.RELEASE.jar
org.springframework.core-3.2.1.RELEASE.jar
org.springframework.expression-3.2.1.RELEASE.jar
org.springframework.jdbc-3.2.1.RELEASE.jar
org.springframework.transaction-3.2.1.RELEASE.jar
org.springframework.web.servlet-3.2.1.RELEASE.jar
org.springframework.web-3.2.1.RELEASE.jar
spring-aop-3.2.1.RELEASE.jar
And I have following other jars as well
commons-beanutils.jar,
commons-collections.jar,
commons-dbcp-1.4.jar,
commons-digester.jar,
commons-io-1.1.jar,
dom4j-1.3.jar,
jackson-core-asl-1.4.2.jar,
jackson-mapper-asl-1.4.2.jar,
jcommon-1.0.16.jar,
jfreechart-1.0.13.jar,
jstl-1.2.jar,
ojdbc6-11.2.0.3.jar,
slf4j.api-1.6.1.jar,
slf4j-nop-1.6.1.jar,
log4j-1.2.17.jar ,
Please help
You obviously have another version of this class in classpath. Do you have spring-beans in system classloader?
As Oracle documentation says, WebLogic web deployment descriptor weblogic.xml has a special element prefer-web-inf-classes.
By setting this element to true, you are changing classloader policy such that classes from application are loaded in preference to system classloader classes.