【发布时间】:2020-02-04 14:41:26
【问题描述】:
'我在从localhost 访问我的应用程序时遇到问题。我通过 Eclipse 在WildFly 服务器版本 17 中添加了项目。
当我打开 localhost:8080/vaadin-app/ui 时,我得到 404 not found。
当我打开localhost:8080/vaadin-app 时,我得到禁止。我在哪里做错了?
会不会是问题与web.xml 文件有关?因为我意识到,web.xml 并不存在。因此我手动创建了它web.xml。
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.kamil.vaadin</groupId>
<artifactId>vaadin-app</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<java.version>1.8.0</java.version>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.5.RELEASE</version>
</parent>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<version>1.3.5.RELEASE</version><!--$NO-MVN-MAN-VER$-->
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-spring-boot-starter</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
</dependencies>
<packaging>war</packaging>
</project>
Main.java:
@SpringUI(path = "/ui")
@Title("First Vaadin Web Application Page")
public class MainView extends UI{
@Override
protected void init(VaadinRequest request) {
final VerticalLayout verticalLayout = new VerticalLayout();
verticalLayout.addComponent(new com.vaadin.ui.Label("Welcome to Vaadin!!!"));
setContent(verticalLayout);
}
}
App.java:
@SpringBootApplication
public class App {
public static void main(String[] args) {
SpringApplication.run(App.class, args);
}
}
web.xml:
<display-name>vaadin-app</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
<welcome-file>ui</welcome-file>
</welcome-file-list>
【问题讨论】:
-
Spring Boot 不需要 web.xml。检查您的日志以了解部署应用程序的上下文。可能它是“”与较新版本的 Spring Boot。您可以使用 localhost:8080/ui 删除您的 web.xml。
标签: java spring-boot tomcat wildfly