Ваадин 14 "не может перейти к" "после перепаковки - PullRequest
1 голос
/ 17 октября 2019

У меня проблема с моим проектом. Может быть, вы можете помочь мне немного. В настоящее время я пытаюсь написать небольшое веб-приложение. Я использую 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>

Мой начальный класс приложения:

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);
    }

}

Будетбудь по-настоящему великим, если бы ты мог мне помочь.

Спасибо!

1 Ответ

1 голос
/ 17 октября 2019

Проблема в том, что ваш класс конфигурации сканирует только пакет, в котором он определен, и все его подпакеты по умолчанию.

Поэтому, чтобы решить вашу проблему, вы должны выполнить одно из следующих действий:

  • определяет дополнительные пакеты для сканирования, которые еще не проверены по умолчанию. Это можно сделать в аннотации @SpringBootApplication с атрибутом scanBasePackages.

  • Переместить класс конфигурации дальше вверх в структуре пакета, чтобы все необходимые Spring-компоненты и представления vaadinнаходятся в том же (или вспомогательном) пакете, что и конфигурация, поэтому они будут сканироваться по умолчанию.

Аналогичный вопрос с несколькими ответами

...