gpt4 book ai didi

java - Vaadin - Spring Boot 定制 Servlet 上的 productionMode

转载 作者:行者123 更新时间:2023-11-30 02:41:25 24 4
gpt4 key购买 nike

我正在尝试将我的项目置于生产模式,但没有成功:(

启动日志上一切似乎都很好:

2017-01-09 09:26:24.453  INFO 80996 --- [           main] c.v.s.b.i.VaadinServletConfiguration     : Registering Vaadin servlet
2017-01-09 09:26:24.453 INFO 80996 --- [ main] c.v.s.b.i.VaadinServletConfiguration : Servlet will be mapped to URLs [/vaadinServlet/*, /VAADIN/*]
2017-01-09 09:26:24.469 INFO 80996 --- [ main] c.v.s.b.i.VaadinServletConfiguration : Setting servlet init parameters
2017-01-09 09:26:24.469 INFO 80996 --- [ main] c.v.s.b.i.VaadinServletConfiguration : Set servlet init parameter [productionMode] = [true]
2017-01-09 09:26:24.470 INFO 80996 --- [ main] c.v.s.b.i.VaadinServletConfiguration : Set servlet init parameter [resourceCacheTime] = [3600]
2017-01-09 09:26:24.470 INFO 80996 --- [ main] c.v.s.b.i.VaadinServletConfiguration : Set servlet init parameter [heartbeatInterval] = [60]
2017-01-09 09:26:24.470 INFO 80996 --- [ main] c.v.s.b.i.VaadinServletConfiguration : Set servlet init parameter [closeIdleSessions] = [true]
2017-01-09 09:26:26.260 INFO 80996 --- [ main] c.v.s.b.i.VaadinServletConfiguration : Checking the application context for Vaadin UI mappings
2017-01-09 09:26:26.263 INFO 80996 --- [ main] c.v.s.b.i.VaadinServletConfiguration : Registering Vaadin servlet of type [com.vaadin.spring.server.SpringVaadinServlet]
2017-01-09 09:26:26.273 INFO 80996 --- [ main] c.v.s.b.i.VaadinServletConfiguration : Forwarding @SpringUI URLs from {/admin/*=org.springframework.web.servlet.mvc.ServletForwardingController@6fc3f1a7, /pages/*=org.springframework.web.servlet.mvc.ServletForwardingController@6fc3f1a7, /dashboard/*=org.springframework.web.servlet.mvc.ServletForwardingController@6fc3f1a7, /admin/*/=org.springframework.web.servlet.mvc.ServletForwardingController@6fc3f1a7, /dashboard/*/=org.springframework.web.servlet.mvc.ServletForwardingController@6fc3f1a7, /pages/*/=org.springframework.web.servlet.mvc.ServletForwardingController@6fc3f1a7}
2017-01-09 09:26:26.283 INFO 80996 --- [ main] c.v.spring.navigator.SpringViewProvider : Looking up SpringViews
2017-01-09 09:26:26.288 INFO 80996 --- [ main] c.v.spring.navigator.SpringViewProvider : 18 SpringViews found
2017-01-09 09:26:26.858 INFO 80996 --- [ main] com.web.Application : Started Application in 26.671 seconds (JVM running for 27.124)

但是当我访问我的应用程序时:

2017-01-09 09:26:32.916  WARN 80996 --- [  XNIO-2 task-1] c.v.s.DefaultDeploymentConfiguration     : 
=================================================================
Vaadin is running in DEBUG MODE.
Add productionMode=true to web.xml to disable debug features.
To show debug window, add ?debug to your application URL.
=================================================================
2017-01-09 09:26:35.613 INFO 80996 --- [ XNIO-2 task-2] c.vaadin.spring.server.SpringUIProvider : Checking the application context for Vaadin UIs
2017-01-09 09:26:35.615 INFO 80996 --- [ XNIO-2 task-2] c.vaadin.spring.server.SpringUIProvider : Found Vaadin UI [com.web.ui.AdminUI]
2017-01-09 09:26:35.616 INFO 80996 --- [ XNIO-2 task-2] c.vaadin.spring.server.SpringUIProvider : Found Vaadin UI [com.web.ui.DashboardUI]
2017-01-09 09:26:35.616 INFO 80996 --- [ XNIO-2 task-2] c.vaadin.spring.server.SpringUIProvider : Found Vaadin UI [com.web.ui.PagesUI]
2017-01-09 09:26:35.616 WARN 80996 --- [ XNIO-2 task-2] c.vaadin.spring.server.SpringUIProvider : Found no Vaadin UIs in the application context
2017-01-09 09:26:36.737 INFO 80996 --- [ XNIO-2 task-8] c.vaadin.spring.server.SpringUIProvider : Checking the application context for Vaadin UIs
2017-01-09 09:26:36.740 INFO 80996 --- [ XNIO-2 task-8] c.vaadin.spring.server.SpringUIProvider : Found Vaadin UI [com.web.ui.AdminUI]
2017-01-09 09:26:36.740 INFO 80996 --- [ XNIO-2 task-8] c.vaadin.spring.server.SpringUIProvider : Found Vaadin UI [com.web.ui.DashboardUI]
2017-01-09 09:26:36.740 INFO 80996 --- [ XNIO-2 task-8] c.vaadin.spring.server.SpringUIProvider : Found Vaadin UI [com.web.ui.PagesUI]
2017-01-09 09:26:36.740 WARN 80996 --- [ XNIO-2 task-8] c.vaadin.spring.server.SpringUIProvider : Found no Vaadin UIs in the application context

我正在为 vaadin 使用自定义 servlet,如果我对其进行注释(并使用 vaadin spring boot 自动配置提供的默认值),则不会出现 DEBUG 信息...

@Bean(name = "springBootServletRegistrationBean")
public ServletRegistrationBean servletRegistrationBean() {
SpringVaadinServlet servlet = new SpringVaadinServlet() {

@Override
protected VaadinServletService createServletService(DeploymentConfiguration deploymentConfiguration) throws ServiceException {
SpringVaadinServletService service = new SpringVaadinServletService(this, deploymentConfiguration, null) {
...

有人知道我做错了什么吗?

最佳答案

尝试将 vaadin.servlet.productMode=true 添加到您的属性文件中。所有其他属性都可以在类中看到:com.vaadin.spring.boot.internal.VaadinServletConfigurationProperties

此外,对于自定义 VaadinServlet,您应该使用以下结构,而不是使用 ServletRegistrationBean:

@Bean
public VaadinServlet vaadinServlet(){
return new SpringVaadinServlet(){
@Override
protected VaadinServletService createServletService(DeploymentConfiguration deploymentConfiguration) throws ServiceException {
SpringVaadinServletService servletService = new SpringVaadinServletService(this, deploymentConfiguration, getServiceUrlPath()) {
// Override any custom method here
}
}
};
}

关于java - Vaadin - Spring Boot 定制 Servlet 上的 productionMode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41579995/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com