Documentation

Documentation versions (currently viewingVaadin 23)

You are viewing documentation for Vaadin 23. View latest documentation

Vaadin Spring Configuration

You can use many properties to configure your Vaadin application. For example, there are the com.vaadin.server.DeploymentConfiguration and com.vaadin.server.Constants classes for the numerous property names. In addition to these properties, you can also set Spring properties as system properties. Spring configuration properties have the same names, but are prefixed with vaadin..

Special Configuration Parameters

There are several special configuration parameters for Spring, such as configuring the scanning of packages, preventing the handling of specific URLs, and more. They’re described in the sections that follow.

Configure the Scanning of Packages

To decrease the startup time during development, as well as the build time for the production bundle, Flow automatically excludes many packages from being scanned for annotations — such as the ones belonging to the java and springframework packages. The set of packages that Vaadin Flow excludes by default are defined in the VaadinServletContextInitializer class.

You can extend this list using the vaadin.blacklisted-packages property, which is a comma-separated string that can be used to exclude packages from being scanned. You would do something like the following:

vaadin.blacklisted-packages=org/bouncycastle,com/my/db/package

The whitelisted-packages is a comma-separated string that can be used to specify the only packages that need to be scanned for UI components and views. You should set this property to improve performance during development, especially in big applications. The com/vaadin/flow/component package is implicitly included and is always scanned.

vaadin.whitelisted-packages=com/foo/myapp/ui,com/foo/components
Note
You should use either whitelisted-packages or blacklisted-packages — not both. If both of them have values, though, blacklisted-packages is ignored.

Prevent Handling of Specific URLs

For some use cases, it’s desirable to exclude specific URLs from being handled by Vaadin, without changing the Vaadin URL mapping. For example, to integrate Swagger-UI, Vaadin should not handle requests for resources accessed by /swagger-ui.html.

The list of URL patterns that should not be handled by the Vaadin servlet, can be configured using the vaadin.exclude-urls property in the form of a comma-separated string.

vaadin.exclude-urls=/swagger-ui/**,/custom-service/**

This configuration only applies when the Vaadin servlet is mapped to the root mapping.

Launch the Browser Automatically in Development Mode

You can configure a Spring Boot project to launch the default browser automatically when starting the application in development mode via the following property:

vaadin.launch-browser = true

Using Spring Boot Properties

You can set properties for Spring Boot in your application.properties file.

An example of this would be setting Spring URL mapping in application.properties:

vaadin.urlMapping=/my_mapping/*

By default, URL mapping is /*.

Note
An additional servlet, such as /my_mapping/*, is required to handle the front-end resources for non-root servlets. The servlet can be defined in your application class. See Application class for an example.

Configuring Spring MVC Applications

If you use Spring MVC, and hence the VaadinMVCWebAppInitializer sub-class, you need to populate your configuration properties.

Setting configuration properties, for example, in a Spring MVC application would look like this:

@Configuration
@ComponentScan
@PropertySource("classpath:application.properties")
public class MyConfiguration {

}

The application.properties file here is still used, but you can use any name and any property source.

58B86F91-8716-4071-AC09-EE19C9A49277