如何将 Vaadin FLOW 服务器推送与 Spring Boot 结合使用

Fra*_*o G 4 server-push vaadin

当我在视图上使用 @Push 注释时,出现以下异常(JDK 16、Vaadin 19.0.7、Spring boot 2.4.7):

org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:162) ~[spring-boot-2.4.7-20210610.075414-42.jar:2.4.7-SNAPSHOT]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:577) ~[spring-context-5.3.8.jar:5.3.8]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:144) ~[spring-boot-2.4.7-20210610.075414-42.jar:2.4.7-SNAPSHOT]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:771) ~[spring-boot-2.4.7-20210610.075414-42.jar:2.4.7-SNAPSHOT]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:763) ~[spring-boot-2.4.7-20210610.075414-42.jar:2.4.7-SNAPSHOT]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:438) ~[spring-boot-2.4.7-20210610.075414-42.jar:2.4.7-SNAPSHOT]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:339) ~[spring-boot-2.4.7-20210610.075414-42.jar:2.4.7-SNAPSHOT]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1329) ~[spring-boot-2.4.7-20210610.075414-42.jar:2.4.7-SNAPSHOT]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1318) ~[spring-boot-2.4.7-20210610.075414-42.jar:2.4.7-SNAPSHOT]
    at net.cbsolution.chameleon.ChameleonApplication.main(ChameleonApplication.java:10) ~[classes/:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78) ~[na:na]
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
    at java.base/java.lang.reflect.Method.invoke(Method.java:567) ~[na:na]
    at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) ~[spring-boot-devtools-2.4.7-20210610.075414-42.jar:2.4.7-SNAPSHOT]
Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
    at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:142) ~[spring-boot-2.4.7-20210610.075414-42.jar:2.4.7-SNAPSHOT]
    at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:104) ~[spring-boot-2.4.7-20210610.075414-42.jar:2.4.7-SNAPSHOT]
    at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:450) ~[spring-boot-2.4.7-20210610.075414-42.jar:2.4.7-SNAPSHOT]
    at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:199) ~[spring-boot-2.4.7-20210610.075414-42.jar:2.4.7-SNAPSHOT]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:181) ~[spring-boot-2.4.7-20210610.075414-42.jar:2.4.7-SNAPSHOT]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:159) ~[spring-boot-2.4.7-20210610.075414-42.jar:2.4.7-SNAPSHOT]
    ... 14 common frames omitted
Caused by: java.lang.IllegalStateException: StandardEngine[Tomcat].StandardHost[localhost].TomcatEmbeddedContext[] failed to start
    at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.rethrowDeferredStartupExceptions(TomcatWebServer.java:187) ~[spring-boot-2.4.7-20210610.075414-42.jar:2.4.7-SNAPSHOT]
    at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:126) ~[spring-boot-2.4.7-20210610.075414-42.jar:2.4.7-SNAPSHOT]
    ... 19 common frames omitted

Run Code Online (Sandbox Code Playgroud)

如何在 Spring boot 中使用服务器推送?有人能指出一个可行的例子吗?

这是完整的日志:

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::       (v2.4.7-SNAPSHOT)

2021-06-20 18:59:24.644  INFO 33309 --- [  restartedMain] n.c.chameleon.ChameleonApplication       : Starting ChameleonApplication using Java 16 on franco-HP-ZBook-15-G5 with PID 33309 (/home/franco/projects/chameleon/target/classes started by franco in /home/franco/projects/chameleon)
2021-06-20 18:59:24.646  INFO 33309 --- [  restartedMain] n.c.chameleon.ChameleonApplication       : No active profile set, falling back to default profiles: default
2021-06-20 18:59:24.672  INFO 33309 --- [  restartedMain] o.s.b.devtools.restart.ChangeableUrls    : The Class-Path manifest attribute in /home/franco/.m2/repository/com/vaadin/license-checker/1.2.0/license-checker-1.2.0.jar referenced one or more files that do not exist: file:/home/franco/.m2/repository/com/vaadin/license-checker/1.2.0/gwt-elemental-2.8.2.vaadin2.jar,file:/home/franco/.m2/repository/com/vaadin/license-checker/1.2.0/oshi-core-5.5.0.jar,file:/home/franco/.m2/repository/com/vaadin/license-checker/1.2.0/jna-5.7.0.jar,file:/home/franco/.m2/repository/com/vaadin/license-checker/1.2.0/jna-platform-5.7.0.jar,file:/home/franco/.m2/repository/com/vaadin/license-checker/1.2.0/slf4j-api-1.7.30.jar
2021-06-20 18:59:24.672  INFO 33309 --- [  restartedMain] o.s.b.devtools.restart.ChangeableUrls    : The Class-Path manifest attribute in /home/franco/.m2/repository/com/oracle/database/jdbc/ojdbc8/19.8.0.0/ojdbc8-19.8.0.0.jar referenced one or more files that do not exist: file:/home/franco/.m2/repository/com/oracle/database/jdbc/ojdbc8/19.8.0.0/oraclepki.jar
2021-06-20 18:59:24.672  INFO 33309 --- [  restartedMain] o.s.b.devtools.restart.ChangeableUrls    : The Class-Path manifest attribute in /home/franco/.m2/repository/com/cronutils/cron-utils/9.1.5/cron-utils-9.1.5.jar referenced one or more files that do not exist: file:/home/franco/.m2/repository/com/cronutils/cron-utils/9.1.5/slf4j-api-1.7.30.jar,file:/home/franco/.m2/repository/com/cronutils/cron-utils/9.1.5/javax.el-3.0.0.jar
2021-06-20 18:59:24.672  INFO 33309 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2021-06-20 18:59:24.672  INFO 33309 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2021-06-20 18:59:25.095  INFO 33309 --- [  restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2021-06-20 18:59:25.130  INFO 33309 --- [  restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 32 ms. Found 6 JPA repository interfaces.
2021-06-20 18:59:25.471  INFO 33309 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2021-06-20 18:59:25.475  INFO 33309 --- [  restartedMain] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2021-06-20 18:59:25.475  INFO 33309 --- [  restartedMain] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.46]
2021-06-20 18:59:25.525  INFO 33309 --- [  restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2021-06-20 18:59:25.525  INFO 33309 --- [  restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 853 ms
2021-06-20 18:59:25.574  INFO 33309 --- [  restartedMain] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2021-06-20 18:59:25.734  INFO 33309 --- [  restartedMain] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2021-06-20 18:59:25.737  INFO 33309 --- [  restartedMain] o.s.b.a.h2.H2ConsoleAutoConfiguration    : H2 console available at '/h2-console'. Database available at 'jdbc:postgresql://localhost:5432/chameleon'
2021-06-20 18:59:25.841  INFO 33309 --- [  restartedMain] c.v.f.s.VaadinServletContextInitializer  : Search for VaadinAppShell took 17 ms
2021-06-20 18:59:25.843  INFO 33309 --- [  restartedMain] c.v.f.s.s.VaadinAppShellInitializer      : Using net.cbsolution.chameleon.MyAppShellConfigurator class for configuring `index.html` response
2021-06-20 18:59:25.848 ERROR 33309 --- [  restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/]       : Exception sending context initialized event to listener instance of class [com.vaadin.flow.spring.VaadinServletContextInitializer$CompositeServletContextListener]

java.lang.RuntimeException: Unable to initialize com.vaadin.flow.spring.VaadinServletContextInitializer$VaadinAppShellContextListener
    at com.vaadin.flow.spring.VaadinServletContextInitializer$FailFastServletContextListener.contextInitialized(VaadinServletContextInitializer.java:192) ~[vaadin-spring-16.0.1.jar:na]
    at com.vaadin.flow.spring.VaadinServletContextInitializer$CompositeServletContextListener.lambda$contextInitialized$0(VaadinServletContextInitializer.java:209) ~[vaadin-spring-16.0.1.jar:na]
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) ~[na:na]
    at com.vaadin.flow.spring.VaadinServletContextInitializer$CompositeServletContextListener.contextInitialized(VaadinServletContextInitializer.java:209) ~[vaadin-spring-16.0.1.jar:na]
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4714) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5172) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
    at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145) ~[na:na]
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:829) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
    at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145) ~[na:na]
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:433) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:930) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
    at org.apache.catalina.startup.Tomcat.start(Tomcat.java:486) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
    at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:123) ~[spring-boot-2.4.7-20210610.075414-42.jar:2.4.7-SNAPSHOT]
    at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:104) ~[spring-boot-2.4.7-20210610.075414-42.jar:2.4.7-SNAPSHOT]
    at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:450) ~[spring-boot-2.4.7-20210610.075414-42.jar:2.4.7-SNAPSHOT]
    at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:199) ~[spring-boot-2.4.7-20210610.075414-42.jar:2.4.7-SNAPSHOT]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:181) ~[spring-boot-2.4.7-20210610.075414-42.jar:2.4.7-SNAPSHOT]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:159) ~[spring-boot-2.4.7-20210610.075414-42.jar:2.4.7-SNAPSHOT]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:577) ~[spring-context-5.3.8.jar:5.3.8]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:144) ~[spring-boot-2.4.7-20210610.075414-42.jar:2.4.7-SNAPSHOT]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:771) ~[spring-boot-2.4.7-20210610.075414-42.jar:2.4.7-SNAPSHOT]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:763) ~[spring-boot-2.4.7-20210610.075414-42.jar:2.4.7-SNAPSHOT]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:438) ~[spring-boot-2.4.7-20210610.075414-42.jar:2.4.7-SNAPSHOT]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:339) ~[spring-boot-2.4.7-20210610.075414-42.jar:2.4.7-SNAPSHOT]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1329) ~[spring-boot-2.4.7-20210610.075414-42.jar:2.4.7-SNAPSHOT]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1318) ~[spring-boot-2.4.7-20210610.075414-42.jar:2.4.7-SNAPSHOT]
    at net.cbsolution.chameleon.ChameleonApplication.main(ChameleonApplication.java:10) ~[classes/:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78) ~[na:na]
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
    at java.base/java.lang.reflect.Method.invoke(Method.java:567) ~[na:na]
    at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) ~[spring-boot-devtools-2.4.7-20210610.075414-42.jar:2.4.7-SNAPSHOT]
Caused by: com.vaadin.flow.server.InvalidApplicationConfigurationException: 

Found app shell configuration annotations in non `AppShellConfigurator` classes.
Please create a custom class implementing `AppShellConfigurator` and move the following annotations to it:
    - @Push from net.cbsolution.chameleon.ui.views.AlertView

    at com.vaadin.flow.server.startup.VaadinAppShellInitializer.init(VaadinAppShellInitializer.java:157) ~[flow-server-6.0.8.jar:6.0.8]
    at com.vaadin.flow.server.startup.VaadinAppShellInitializer.init(VaadinAppShellInitializer.java:94) ~[flow-server-6.0.8.jar:6.0.8]
    at com.vaadin.flow.spring.VaadinServletContextInitializer$VaadinAppShellContextListener.failFastContextInitialized(VaadinServletContextInitializer.java:550) ~[vaadin-spring-16.0.1.jar:na]
    at com.vaadin.flow.spring.VaadinServletContextInitializer$FailFastServletContextListener.contextInitialized(VaadinServletContextInitializer.java:188) ~[vaadin-spring-16.0.1.jar:na]
    ... 47 common frames omitted

2021-06-20 18:59:25.848 ERROR 33309 --- [  restartedMain] o.apache.catalina.core.StandardContext   : One or more listeners failed to start. Full details will be found in the appropriate container log file
2021-06-20 18:59:25.849 ERROR 33309 --- [  restartedMain] o.apache.catalina.core.StandardContext   : Context [] startup failed due to previous errors
2021-06-20 18:59:25.852  WARN 33309 --- [  restartedMain] o.a.c.loader.WebappClassLoaderBase       : The web application [ROOT] appears to have started a thread named [HikariPool-1 housekeeper] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 java.base@16/jdk.internal.misc.Unsafe.park(Native Method)
 java.base@16/java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:252)
 java.base@16/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:1661)
 java.base@16/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1182)
 java.base@16/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:899)
 java.base@16/java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1056)
 java.base@16/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1116)
 java.base@16/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
 java.base@16/java.lang.Thread.run(Thread.java:831)
2021-06-20 18:59:25.853  WARN 33309 --- [  restartedMain] o.a.c.loader.WebappClassLoaderBase       : The web application [ROOT] appears to have started a thread named [HikariPool-1 connection adder] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 java.base@16/java.lang.String.equals(String.java:1027)
 java.base@16/sun.security.ssl.CipherSuite.nameOf(CipherSuite.java:898)
 java.base@16/sun.security.ssl.SSLAlgorithmDecomposer.decompose(SSLAlgorithmDecomposer.java:262)
 java.base@16/sun.security.util.AbstractAlgorithmConstraints.checkAlgorithm(AbstractAlgorithmConstraints.java:99)
 java.base@16/sun.security.util.DisabledAlgorithmConstraints.permits(DisabledAlgorithmConstraints.java:140)
 java.base@16/sun.security.ssl.SSLAlgorithmConstraints.permits(SSLAlgorithmConstraints.java:164)
 java.base@16/sun.security.ssl.SSLAlgorithmConstraints.permits(SSLAlgorithmConstraints.java:154)
 java.base@16/sun.security.ssl.HandshakeContext.isActivatable(HandshakeContext.java:550)
 java.base@16/sun.security.ssl.HandshakeContext.getActiveCipherSuites(HandshakeContext.java:339)
 java.base@16/sun.security.ssl.HandshakeContext.<init>(HandshakeContext.java:185)
 java.base@16/sun.security.ssl.ClientHandshakeContext.<init>(ClientHandshakeContext.java:98)
 java.base@16/sun.security.ssl.TransportContext.kickstart(TransportContext.java:238)
 java.base@16/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:434)
 java.base@16/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:412)
 app//org.postgresql.ssl.MakeSSL.convert(MakeSSL.java:41)
 app//org.postgresql.core.v3.ConnectionFactoryImpl.enableSSL(ConnectionFactoryImpl.java:534)
 app//org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:149)
 app//org.

cfr*_*ick 8

您必须将“整个”应用程序(即@Push )的注释添加到您的中央配置位置(即实现的类 AppShellConfigurator)。正如错误所述:

Found app shell configuration annotations in non `AppShellConfigurator` classes.
Please create a custom class implementing `AppShellConfigurator` and move the following annotations to it:
  - @Push from net.cbsolution.chameleon.ui.views.AlertView
Run Code Online (Sandbox Code Playgroud)

@Push从中删除net.cbsolution.chameleon.ui.views.AlertView(因为它已经设置在您的MyAppShellConfigurator代码粘贴中)。

  • @FrancoG `AppShellConfigurator` 仅在 Vaadin 15+ 后可用,而您链接的文档适用于 Vaadin 14。在 V14 中,`@Push` 注释应该位于根布局或视图类中。要使用较新的 Vaadin 版本,您需要的文档位于 /latest - https://vaadin.com/docs/latest/flow/overview 下,或者选择页面上左上角的版本。 (4认同)
  • 非常感谢。奇迹般有效。从文档(https://vaadin.com/docs/v14/flow/advanced/tutorial-push-access)中,我得到的印象是@push注释应该用于所有可能成为推送目标的视图。 (3认同)