Vaadin 14如何将Vaadin Servlet移动到不同的URL?

huangapple go评论87阅读模式
英文:

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

huangapple
  • 本文由 发表于 2020年8月13日 21:24:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/63396205.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定