Spring Boot 2.0.2 - Missing classes MetricRepositoryAutoConfiguration, MetricFilterAutoConfiguration - spring-boot

in Spring Boot 1.5 application the application class was annotated with:
#EnableAutoConfiguration(exclude = {MetricFilterAutoConfiguration.class, MetricRepositoryAutoConfiguration.class})
These classes were I believe in the package:
import org.springframework.boot.actuate.autoconfigure.*;
Now upgrade to Spring Boot 2.0.2 but those classes are missing, can't find them anywhere.
What changed? How to solve?
Thanks!

Spring Boot’s own metrics have been replaced with support, including
auto-configuration, for Micrometer and dimensional metrics.
if you want to disable metrics set management.endpoint.metrics.enabled=false
there is a complete guide that makes migration a lot easier
Spring Boot 2.0 Migration Guide

Related

Are extra reflection configurations needed for custom Spring Boot starter libraries when using Spring Native?

I am in the process of building a set of shared libraries using custom Spring Boot starter auto configuration per guidance from https://docs.spring.io/spring-boot/docs/2.6.7/reference/htmlsingle/#features.developing-auto-configuration. Great feature offered by Spring Boot by the way! My question is that how does Spring Native support these types of custom Spring Boot Starter libraries? Are extra reflection configurations or native hints required? I have been evaluating Spring Native and I am very excited about the performance boost it brings to Spring Boot apps! I am eagerly awaiting Spring Boot 3 GA to be released! Any advice on how Spring Boot 3 and/or Spring Native handles custom Spring Boot starter libraries and if any extra configurations are required will be greatly appreciated!
I reached out to Sébastien Deleuze, one of the members on Spring Native team, and his response to my question is as follows. Thanks Sébastien!
"Spring Native and the upcoming Spring Boot 3 should support this kind of autoconfiguration if they follow certain guidelines, like using #Configuration(proxyBeanMethods=false).
See https://docs.spring.io/spring-native/docs/current/reference/htmlsingle/#how-to-contribute-design for more details.
Spring Boot 3 will likely define more clearly the guidelines."

Spring Boot 2.x Metrics classes

I have started using spring boot 2.0.0-Snapshot and I see that all Metric related classes and interfaces does not exists ?
Example:
The jar spring-boot-actuator-2.0.0.BUILD-SNAPSHOT.jar does not have package
org.springframework.boot.actuate.metrics.writer at all
Are they moved to somewhere else?
In Spring Boot 2 the previous metrics implementation has been replaced by integration with Micrometer. From the release notes:
Spring Boot’s own metrics have been replaced with support, including auto-configuration, for Micrometer and dimensional metrics. You can learn more about Micrometer in its user manual and Spring Boot’s reference guide
I can't find any guide for migrating from 1.x Spring Boot Metrics to 2.x Spring Boot Metrics but this change is quite recent so I suspect any such docs are a TODO. In the meantime, you could perhaps dig into the Pull Request or follow the Spring Boot 2 docs ...
Micrometer provides a separate module for each supported monitoring system. Depending on one (or more) of these modules is sufficient to get started with Micrometer in your Spring Boot application. To learn more about Micrometer’s capabilities, please refer to its reference documentation.

Does #NodeEntityScan exist in Spring Boot 1.4.0.RELEASE?

According to http://docs.spring.io/spring-boot/docs/1.4.0.RELEASE/reference/htmlsingle/#boot-features-neo4j there is a #NodeEntityScan annotation that:
You can customize entity scanning locations using the #NodeEntityScan annotation.
According to http://docs.spring.io/spring-boot/docs/1.4.0.M3/api/org/springframework/boot/neo4j/NodeEntityScan.html it existed in version spring-boot 1.4.0.M3
But http://docs.spring.io/spring-boot/docs/1.4.0.RELEASE/api/org/springframework/boot/neo4j/NodeEntityScan.html suggests it doesn't exist in 1.4.0.RELEASE and I can't find any mention of it.
Does this annotation exist in spring boot 1.4.0.RELEASE ? Is this a case where the documentation has not been updated? What should be used instead?
Spring Boot 1.4 has the generic annotation org.springframework.boot.autoconfigure.domain.EntityScan (JavaDoc), which registers the packages to scan for entities for JPA, Neo4J, MongoDB, Cassandra and Couchbase.

Minimum version of spring for spring-boot v 1.3

I have an existing spring application built using spring framework version 3.1.2. I am trying to create a spring-boot application out of this existing application, but getting some dependency issues. So just wondering, what is the spring framework version, that is supported by spring-boot v 1.3.0.
Or to put it in another words, is it possible to have a spring-boot application from a spring 3.1.2 based application?
Spring boot has hard dependencies on classes in Spring 4 and could not be configured to work with Spring 3. If you are really interested in using Spring Boot the only way you can do this is to follow a migration path to Spring 4 and then add Spring Boot to your application.
It is worth mentioning that the "boot" in Spring Boot is meant to be short for bootstrapping, as in initial setup of an application. I'm not saying there would be zero benefits from migrating from Spring 4 vanilla to Spring Boot. But make sure you are migrating for the right reasons the main purpose of Spring Boot is easy bootstrapping of applications but here are some other features which might be worth making the move.
Spring Boot dev-tools (Auto restart on code changes)
Awesome spring boot plugins for maven and gradle to ease upgrading spring in the future (hint it upgrades many other dependencies for you)
Bootstrapping new features such as MongoDb through auto-configuration.
Migration from 3.1 to 3.2
https://docs.spring.io/spring/docs/3.2.x/spring-framework-reference/html/migration-3.2.html
Migration from Spring 3 to Spring 4.
https://spring.io/blog/2014/01/30/migrating-from-spring-framework-3-2-to-4-0-1
There are many features in spring boot that are dependent upon new features added to Spring 4. One primary example is the new list of annotations added to Spring 4 that allow conditional wiring/loading of beans. Which is the primary method of wiring configurations in a plugin-like way.
For example lets see the AutoConfiguration class for the H2 console
https://github.com/spring-projects/spring-boot/blob/master/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/h2/H2ConsoleAutoConfiguration.java
The first thing we see is it's wired to be a Configuration class. It will only load if WebServlet.class is on the classpath and if the property spring.h2.console is = true. It is also configured to load SecurityAutoConfiguration first as this is a dependency at least for securing the h2 console page.
#Configuration
#ConditionalOnWebApplication
#ConditionalOnClass(WebServlet.class)
#ConditionalOnProperty(prefix = "spring.h2.console", name = "enabled", havingValue = "true", matchIfMissing = false)
#EnableConfigurationProperties(H2ConsoleProperties.class)
#AutoConfigureAfter(SecurityAutoConfiguration.class)
public class H2ConsoleAutoConfiguration {
When this Configuration is loaded it will check these conditions and upon all conditions being true then and only then will it load in the beans defined in the class. In this case it wires the h2console servlet.
#Bean
public ServletRegistrationBean h2Console() {
String path = this.properties.getPath();
String urlMapping = (path.endsWith("/") ? path + "*" : path + "/*");
return new ServletRegistrationBean(new WebServlet(), urlMapping);
}
There is also the security configuration in that class which introduces one more concept of conditionally loading a configuration based on another class being loaded into the context. These annotations do not always need to be on a Configuration level but can also apply to the bean level.
These concepts are core to how Spring Boot is implemented and therefore could not work with Spring 3.
Spring 3 list of annotations
http://docs.spring.io/spring/docs/3.0.x/javadoc-api/org/springframework/context/annotation/
Spring 4 Conditional Annotations
https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/context/annotation/
Thanks Zergleb for posting detailed answer. I found a way to run the spring 3 app as an independent jar by created an uber jar with a little instrumentation to bootstrap spring through a java class.
It is explained nicely in a short post at https://mihhaillapushkin.wordpress.com/2013/02/18/spring-3-for-standalone-applications

Basic interrogation about Spring boot and #EnableAutoConfiguration

I have a basic question about Spring Boot:
Say I am developping a websocket app. It seems the idea behind Spring Boot is as follows:
As a developer I am responsible for:
Including the following mvn dependency: spring-boot-starter-websocket
Annotate my configuration class with: #EnableAutoConfiguration
Spring Boot is then responsible for applying the following config: WebSocketAutoConfiguration
In a nutshell, is it how it works? Can someone please confirm of infirm the above?
You are absolutely correct.
After adding spring-boot-starter-websocket to your configuration file and using the #EnableAutoConfiguration annotation, Spring will use you class path to automatically determine which configuration settings and beans need to be created for you.
Spring Boot will handle the WebSocketAutoConfiguration and any other necessary common configurations.
More information can be found here: https://spring.io/guides/gs/spring-boot/

Resources