@EnableWebFlux и тимелиф не работают вместе - PullRequest
0 голосов
/ 11 апреля 2019

Существуют ли какие-либо ограничения на использование тимелина с приложением Springboot с основным классом с комментариями @ EnableWebFlux.

Если я просто прокомментирую @EnableWebFlux в следующем классе, все будет работать.Потраченные впустую 2 дня просто, чтобы найти, где комментировать, чтобы все заработало:).

@EnableWebFlux
@SpringBootApplication(exclude = {GsonAutoConfiguration.class})
public class BootApplication {

    public static void main(String[] args)
    {
        SpringApplication springApplication = new SpringApplication(BootApplication.class);
        springApplication.setWebApplicationType(WebApplicationType.REACTIVE);
        springApplication.run(args);
    }
}

Раскомментируя его, я не могу открыть ни одну из моих html-страниц, и показанная ниже ошибка:

Страница ошибки Whitelabel Это приложение не имеет настроенного представления ошибок, поэтому вы видите это как запасной вариант.

Четверг 11 апреля 20:20:13 IST 2019 Произошла непредвиденная ошибка (тип = Внутренняя ошибка сервера, статус =500).Не удалось разрешить представление с именем 'index'.

Ниже представлен класс моего контроллера:

@Controller
public class SimpleController {
    @Value("${spring.application.name}")
    String appName;

    @GetMapping(path="/home", produces = "text/html")
    public String homePage(Model model) {
        //model.addAttribute("appName", appName);
        return "home";
    }

    @RequestMapping(value = "/", method = RequestMethod.GET)
    public String index(final Model model) {

        // data streaming, data driven mode.
        IReactiveDataDriverContextVariable reactiveDataDrivenMode =
                new ReactiveDataDriverContextVariable(Flux.just("a") , 1);

        model.addAttribute("movies", reactiveDataDrivenMode);

        return "index";

    }
}

application.properties:

server.port=8099
spring.thymeleaf.cache=false
spring.thymeleaf.enabled=true
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html

spring.application.name=Bootstrap Spring Boot

pom.xml:

<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>

    <groupId>com.nano</groupId>
    <artifactId>thymeleaf</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>thymeleaf</name>
    <url>http://maven.apache.org</url>

    <properties>
        <log4jVersion.version>2.10.0</log4jVersion.version>
        <slf4jVersion.version>1.7.25</slf4jVersion.version>
        <springBoot.version>2.1.3.RELEASE</springBoot.version>
        <jackson.version>2.9.8</jackson.version>
        <buildGroup>d</buildGroup>
        <buildName>e</buildName>
        <deployable>true</deployable>

    </properties>

    <repositories>
        <repository>
            <id>spring-snapshots</id>
            <name>Spring Snapshots</name>
            <url>http://repo.spring.io/libs-snapshot</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>file</id>
            <releases>
                <enabled>true</enabled>
                <checksumPolicy>ignore</checksumPolicy>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
            <url>file://${project.basedir}/lib</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <version>${springBoot.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-webflux</artifactId>
            <version>${springBoot.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
            <version>${springBoot.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
            <version>${springBoot.version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>${jackson.version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>${jackson.version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <version>${jackson.version}</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${slf4jVersion.version}</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>log4j-over-slf4j</artifactId>
            <version>${slf4jVersion.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>${log4jVersion.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
            <version>${log4jVersion.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-slf4j-impl</artifactId>
            <version>${log4jVersion.version}</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <!--<version>3.1</version> -->
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-source-plugin</artifactId>
                <version>3.0.0</version>
                <configuration>
                    <skipSource>false</skipSource>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>sonar-maven-plugin</artifactId>
                <version>2.6</version>
            </plugin>
        </plugins>
    </build>
</project>
...