英文:
Vaadin 14 how to move the vaadin servlet to a different URL?
问题
I have a pretty basic vaadin application running. The application is spring-boot backed and I defined some rest API.
I've added OpenAPI documentation using org.springdoc:springdoc-openapi-ui:1.4.4, which worked perfectly before adding vaadin.
After adding the vaadin dependencies as shown in the vaadin spring-boot tutorial, and creating a view (which works), the swagger UI is no longer reachable.
It seems to me that vaadin completely takes over all web requests. Digging deeper, I've found that vaadin registers a new servlet and catches all requests.
I don't find any docs on how to configure this -- I'd expect that one could configure vaadin such that it serves UI from a different path, say /ui
or similar.
I've tried to set
vaadin:
url-mapping: "/ui/*"
in my application.yaml
-- but this results in blank pages (no errors) for my vaadin views,
and the vaadin servlet does still take over /
.
I use spring.boot 2.3.2.RELEASE
, vaadin 14.3.1
.
英文:
I have a pretty basic vaadin application running. The application is spring-boot backed and I defined some rest API.
I've added OpenAPI documentation using org.springdoc:springdoc-openapi-ui:1.4.4, which worked perfectly before adding vaadin.
After adding the vaadin dependencies as shown in the vaadin spring-boot tutorial, and creating a view (which works), the swagger UI is no longer reachable.
It seems to me that vaadin completely takes over all web requests. Digging deeper, I've found that vaadin registers a new servlet and catches all requests.
I don't find any docs on how to configure this -- I'd expect that one could configure vaadin such that it serves UI from a different path, say /ui
or similar.
I've tried to set
vaadin:
url-mapping: "/ui/*"
in my application.yaml
-- but this results in blank pages (no errors) for my vaadin views,
and the vaadin servlet does still take over /
.
I use spring.boot 2.3.2.RELEASE
, vaadin 14.3.1
.
答案1
得分: 3
The value to override is (note the camelCase instead of the kebab-case):
vaadin:
urlMapping: /ui/*
Using the kebab-case did (does) not work. As expected, this is a bug. See https://github.com/vaadin/spring/issues/637
From the docs at the point of time:
> You can set properties for Spring Boot in your application.properties
file.
>
> Example: Setting Spring URL mapping in application.properties
.
>
> > vaadin.urlMapping=/my_mapping/* >
>
> By default, URL mapping is /*
.
>
> > An additional servlet, such as /my_mapping/*
, is required to handle the frontend resources for non-root servlets. The servlet can be defined in your application class. See this Application class for an example.
> ---
> Source: https://vaadin.com/docs/v14/flow/spring/tutorial-spring-configuration.html#using-spring-boot-properties
英文:
The value to override is (note the camelCase instead of the kebab-case):
vaadin:
urlMapping: /ui/*
Using the kebab-case did (does) not work. As expected, this is a bug. See https://github.com/vaadin/spring/issues/637
From the docs at the point of time:
> You can set properties for Spring Boot in your application.properties
file.
>
> Example: Setting Spring URL mapping in application.properties
.
>
>
> vaadin.urlMapping=/my_mapping/*
>
>
> By default, URL mapping is /*
.
>
> > An additional servlet, such as /my_mapping/*
, is required to handle the frontend resources for non-root servlets. The servlet can be defined in your application class. See this Application class for a example.
> ---
> Source: https://vaadin.com/docs/v14/flow/spring/tutorial-spring-configuration.html#using-spring-boot-properties
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论