What’s left to configure with Spring boot?

Asked

Viewed 1,131 times

1

The settings I use with spring are based on Java class, as in this example https://github.com/matheussilvasantos/autocomplete.

If this project used the spring boot, what settings would still be needed to configure in the classes?

I looked at an example where to set up an Interceptor with the spring boot, created a class to configure, so there is a limit to the spring boot, how far it is possible to configure with the application properties?

1 answer

6


Configuring with Spring Boot

If this project used spring boot, what settings would still be needed to configure in the classes?

In fact, you could remove part of the settings, because the idea of Spring Boot is precisely to join the most used components of Spring using some conventions and avoid that you need to do it manually.

So much so that Spring Boot actually has "flavors" ready for the most common types of application. See the list here.

Num simple example of web design, you can check that the only necessary configuration was:

@SpringBootApplication
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}

Application properties

I looked at an example where to configure an Interceptor with spring boot, they created a class to configure, so it has a limit for spring boot, as far as it is possible to configure with the application.properties?

The application.properties is not a replacement for application configuration. It is only a facilitator for the most common configuration variations. This helps a lot in most cases, but in a non-trivial application it is almost inevitable that you do not have to use settings via annotations or even via XML, depending on your purpose.

See here the list of most common settings.

The recommended way for configuration is to use annotations. For example, to declare a new bean, just declare a method in any configuration class whose return is the instance and annotate the method with @Bean.

There is nothing wrong or unwanted side effects in making this type of configuration, so don’t spend time trying to escape it unless you are using some standard functionality easily activated by application.properties.

Examples and migration

I have several examples of projects using Spring Boot on my Github.

I believe the easiest way for you to use Springboot in your project is to first change the configuration (pom.xml) according to the examples, then the application configuration (annotations and methods of the configuration classes).

You probably won’t need any changes to the system itself, other than maybe moving somewhere to fit the Spring Boot pattern. So, it’s just a matter of transposing the way you set up and over time you’ll discover what Spring Boot offers more easily.

However, Spring Boot is not much more than Spring with conventions, so a good application might not have gained any in migrating.

  • would you tell me if I can set up an Interceptor (Handlerinterceptoradapter) as in Spring MVC in Spring Boot?

  • @Matheus The principle, yes, but there is more than one way. Please avoid off-topic comments, ask a new question.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.