Created a new Spring Initializer project in IntelliJ using Spring Boot version 3.0.2.
Included Spring Web and Spring Boot Actuator.
Did the same using Spring Boot version 2.7.8.
Both projects have the following in application.properties
management.endpoints.web.exposure.include=info
management.info.build.enabled=true
spring.jackson.serialization.indent-output=true
When requesting /actuator/info for version 3.0.2 project, the JSON is not indented or pretty printed.
The same request for version 2.7.8 project returns pretty printed and indented JSON.
Everything is left default, no code additions, config changes. etc. Just plain vanilla out of the box project.
Is this a bug in Spring Boot version 3?
Expected the JSON response to be pretty printed and indented as per the Spring documentation for the Application Properties settings.
This change has been introduced in Spring Boot 3 on purpose: changing a JSON configuration in your main application should not change the JSON format used by actuator, as it could confuse clients relying on the format to be the same for all Spring Boot applications.
See the related issuue and also the dedicated section in the migration guide. You can revert to the previous behavior by setting the management.endpoints.jackson.isolated-object-mapper=false configuration property.
Related
In Spring Boot, for multipart uploads, I see many of the tutorial sites suggests to have one of the below properties:
spring.http.multipart.enabled=false
or
spring.servlet.multipart.enabled=true
Can someone explain why these settings and their use cases? Especially if I set the property spring.http.multipart.enabled=false , then why spring.servlet.multipart.enabled=true
I tried searching through Stack Overflow, but did not find any relevant posts for this one.
spring.http.multipart.enabled has been replaced with spring.servlet.multipart.enabled
If you're using Spring Boot 2.0.0 or later you should use spring.servlet.multipart.enabled
See also:
additional-spring-configuration-metadata.json
Spring Boot Reference of 1.5.19.RELEASE version (the Common application properties section lists spring.http.multipart.enabled).
Spring Boot reference of 2.0.0.RELEASE version (replaced with spring.servlet.multipart.enabled)
Upgrading from an Earlier Version of Spring Boot
MultipartProperties (1.5.19.RELEASE)
MultipartProperties (2.0.0.RELEASE)
I use Spring Boot 2.0.4.RELEASE with Flyway 5.1.4. When starting my Spring Boot application I get the warning Flyway.setCallbacks(FlywayCallback) has been deprecated and will be removed in Flyway 6.0. Use Flyway.setCallbacks(Callback) instead.
This seems to be caused by Spring Boot as I don't configure any callbacks myself. Is there any way to disable this warning or prevent its root cause?
The problem is occurring because you are using Flyway 5.1 with Spring Boot 2.0. Spring Boot 2.0 compiles against, and provides dependency management for, Flyway 5.0 where the setCallbacks(FlywayCallback[]) has not been deprecated and does not generate a warning when called.
If you want to continue using Boot's auto-configuration then, at the time of writing, you have a couple of options:
Drop back to Flyway 5.0.x by remove your override of Flyway's version and allowing Spring Boot's dependency management to control the version.
Customise your logging configuration so that the warning isn't logged.
It should be possible to improve the situation in Spring Boot 2.0.x. Currently, setCallbacks(FlywayCallback[]) is called even when the array is empty. That's benign with Flyway 5.0, but unnecessarily generates the warning you are seeing with 5.1. This issue will address that.
I have a Spring boot (v1.5.9) based application with Jolokia provided by Spring boot actuator.
Jolokia works fine. I can read values, for example:
http://localhost:8080/jolokia/read/java.lang:type=ClassLoading/Verbose
gives me:
{"request":{"mbean":"java.lang:type=ClassLoading","attribute":"Verbose","type":"read"},"value":false,"timestamp":1527859447,"status":200}
What I want is to disable writing operations, for example:
http://localhost:8080/jolokia/write/java.lang:type=ClassLoading/Verbose/true
The spring boot configuration looks like this:
management.security.enabled=false
management.endpoints.jmx.exposure.exclude=*
management.endpoints.web.exposure.include=jolokia,metrics
management.endpoint.jolokia.config.policyLocation=classpath:/jolokia.xml
And the Jolokia's policy in WEB-INF\classes\jolokia.xml (in resulting war, according to https://jolokia.org/reference/html/security.html) contains:
<restrict>
<commands>
<command>read</command>
<command>list</command>
<command>version</command>
<command>search</command>
</commands>
</restrict>
Despite this I see the following note in application's log:
jolokia: No access restrictor found, access to any MBean is allowed
And the write operation from the example above is working fine.
What I'm doing wrong? Should I put the policy file somewhere else? Is it possible to configure Jolokia's policy directly from the Spring boot configuration?
It looks like you've inadvertently used Spring Boot 2.0 configuration properties with Spring Boot 1.5.x. In 1.5 you should use jolokia.config.policyLocation. There's a little more information in the reference documentation.
I am trying to make a filedownload endpoint for my ftp server. I see that there is a Spring boot integration starter module for Spring boot but this module doesen't contain classes like DefaultFtpSessionFactory . I've read on the web that there are other modules available like Spring integration http and Spring integration ftp. However, these are not spring boot modules. Is it save to include those modules in my POM anyway? Or shoulden't I use Spring boot starter integration in the first place?
I see in this example: https://blog.pavelsklenar.com/spring-integration-sftp-upload-example/ That the author is using spring boot next to Spring Integration 4.3.8 regular Spring. He does say those are managed by Spring boot but i'm not exactly sure what he means by that.
Can anyone tell me what modules I should include if I want to make the download function? Thanks
Since it's unlikely that an application would require all Spring Integration modules (ftp, sftp, http, mqtt, ... etc), the starter only includes the core and java dsl jars on the classpath (in Spring Integration 5.0, the DSL is built in so boot 2.0 only includes the core jar).
Otherwise, you'd end up with many jars on the classpath that you don't need.
So, yes, you have to manually add the dependencies you need...
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-ftp</artifactId>
</dependency>
Note that you don't need a <version/> - boot will manage that for you and bring in the right version corresponding to the core.
The modules themselves will bring in any additional transitive dependencies they need. So you just need to add the top level module(s) to your pom.
What's the best method to initiate a new Spring Project ?
Initiating Spring project is a lot of pain with various xml and db configuration.
Is there an "official" repository with complete sample project, as MVC with db access and so ?
Spring Boot may also be the solution, but some point still not clear to me :
How to add external components (such as Quartz) without creating some xml config ? (No such xml in Boot apparently)
Is a Spring Boot builded app is production-proof ?
As writen in the comments http://start.spring.io/ is the best way to start Spring boot project(STS has integration for it).
If you want to use something that is not supported by Spring Boot you can init spring beans the same way you do it in xml, just use java configuration. See this for example: http://www.tutorialspoint.com/spring/spring_java_based_configuration.htm
Also useing xml is still available. You can add #ImportResource on your Configuration class
#EnableAutoConfiguration
#Configuration
#ImportResource({"classpath*:applicationContext.xml"})