Vaadin - productionMode on Spring 启动定制的 Servlet
Vaadin - productionMode on Spring Boot customized Servlet
我正在尝试将我的项目置于生产模式,但没有成功:(
启动日志上的一切似乎都很好:
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 启动自动配置提供的默认值),则不会出现 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.productionMode=true
添加到您的属性文件。所有其他属性都可以在class中看到: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
}
}
};
}
我正在尝试将我的项目置于生产模式,但没有成功:(
启动日志上的一切似乎都很好:
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 启动自动配置提供的默认值),则不会出现 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.productionMode=true
添加到您的属性文件。所有其他属性都可以在class中看到: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
}
}
};
}