java - Vaadin 14 'could not navigate to "' 重新包装后

标签 java maven spring-boot vaadin

我的项目有问题。也许你可以帮我一点忙。 我目前正在尝试编写一个小网络应用程序。我使用 Spring Boot + Vaadin 14。 当我在 Eclipse 中测试应用程序时,一切都按设计进行。但是在我使用 Maven 编译我的项目并启动它之后,我收到一条错误消息,指出我的应用程序找不到任何路由。

这是错误消息:

Could not navigate to ''
Reason: Couldn't find route for ''

Available routes:
This detailed message is only shown when running in development mode.

这是我的 pom:

?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.9.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>
    <groupId>(REMOVED FOR PRIVACY REASONS)</groupId>
    <artifactId>(REMOVED FOR PRIVACY REASONS)</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>mobileissuecreator</name>
    <packaging>jar</packaging>

    <properties>
        <java.version>1.8</java.version>
        <vaadin.version>14.0.9</vaadin.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-spring-boot-starter</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-spring-boot-starter</artifactId>
        </dependency>
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.vaadin</groupId>
                <artifactId>vaadin-bom</artifactId>
                <version>${vaadin.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

我的应用程序入门类(class):

package com.cen.spin.mobileissuecreator.springcontroller;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.context.annotation.SessionScope;


import com.vaadin.flow.spring.annotation.EnableVaadin;

@Configuration
@SpringBootApplication
@EnableVaadin("(REMOVED FOR PRIVACY REASONS)")
public class (REMOVED FOR PRIVACY REASONS) extends SpringBootServletInitializer {

    public static void main(String[] args) {
        SpringApplication.run((REMOVED FOR PRIVACY REASONS).class, args);
    }

    @Bean
    @SessionScope
    public MICService micService(EnoviaAuthService enoviaAuthService, EnoviaAuthProperties enoviaAuthProperties) {
        return new MICService(enoviaAuthService, enoviaAuthProperties);
    }

    @Bean
    @SessionScope
    public EnoviaAuthService enoviaAuthService(EnoviaAuthProperties enoviaAuthProperties) throws Exception {
        return new EnoviaAuthService(enoviaAuthProperties);
    }

    @Bean
    @SessionScope
    public EnoviaAuthProperties enoviaAuthProperties() {
        return new EnoviaAuthProperties();
    }

    @Bean
    @SessionScope
    public EnoviaRoleSelectorService enoviaRoleSelectorService(EnoviaAuthService enoviaAuthService) {
        return new EnoviaRoleSelectorService(enoviaAuthService);
    }

    @Bean
    @SessionScope
    public EnoviaContextCheckService enoviaContextCheckService(EnoviaAuthService enoviaAuthService) {
        return new EnoviaContextCheckService(enoviaAuthService);
    }

}

如果你能帮助我,那就太好了。

谢谢!

最佳答案

问题是因为你的配置类默认只扫描定义它的包及其所有子包。

因此,为了解决您的问题,您应该执行以下操作之一:

  • 定义要扫描的其他包,默认情况下尚未扫描这些包。您可以在 @SpringBootApplication 注释中使用 scanBasePackages 属性执行此操作。

  • 将配置类在包结构中进一步向上移动,以便所有必需的 spring-components 和 vaadin View 都与配置位于同一(或子)包中,因此默认情况下将扫描它们。

Similar question with multiple answers

关于java - Vaadin 14 'could not navigate to "' 重新包装后,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58426408/

相关文章:

java - 具有多个应用程序上下文的 Spring MVC 应用程序

java - 无法加载 JDBC 驱动程序。为什么? ( Spring , hibernate )

java - 如何将大型依赖树从 Maven Central 推送到本地 Archiva 服务器?

java - 如何打包 Spring Boot 应用程序以作为另一个 Spring Boot 应用程序中的操作依赖项

java - 何时在 Springs @Configuration 中将 proxyBeanMethods 设置为 false?

java - JPA只指RDBMS吗

java - 哪个版本的 spring data mongo db 带有 mongo java driver 3.0.2 和 spring Framework 3.2.2.Release

java - 如何在一个@Async中使用不同的执行器

maven - 防止 Flyway Maven 插件下载旧的 slf4j jar

java - Spring Boot Hibernate 一对多无限递归