gpt4 book ai didi

java - undertow 编译错误

转载 作者:太空宇宙 更新时间:2023-11-04 14:26:09 25 4
gpt4 key购买 nike

我正在使用 undertow 开发一个 web 应用程序,并且对 java 相当陌生。运行 ServeletEngine.java 时出现错误。我检查了其他相关帖子,但他们没有解决我的疑问。请帮我。

错误:[错误]无法在项目undertow-server上执行目标org.apache.maven.plugins:maven-compiler-plugin:2.3.2:编译(默认编译):编译失败:编译失败:

我的目录结构是:〜/undertow-server/src/main/java/com/mastertheboss/undertow/ServeletEngine.java

我的 pom.xml 文件是: $ cat ~/undertow-server/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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mastertheboss.undertow</groupId>
<artifactId>undertow-server</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>undertow-server</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>io.undertow</groupId>
<artifactId>undertow-core</artifactId>
<version>1.0.1.Final</version>
</dependency>
<dependency>
<groupId>io.undertow</groupId>
<artifactId>undertow-servlet</artifactId>
<version>1.0.1.Final</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>com.mastertheboss.undertow.ServeletEngine</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</project>

ServeletEngine.java 位于:$ cat ~/undertow-server/src/main/java/com/mastertheboss/undertow/ServletEngine.java 包 com.mastertheboss.undertow; 导入 io.undertow.Undertow; 导入 io.undertow.server.*; 导入 io.undertow.util.Headers;

public class ServletEngine {


public static final String MYAPP = "/myapp";

public static void main(final String[] args) {

try {

DeploymentInfo servletBuilder = deployment()
.setClassLoader(ServletEngine.class.getClassLoader())
.setContextPath(MYAPP)
.setDeploymentName("test.war")
.addListener(new ListenerInfo(MySessionListener.class))

.addServlets(
servlet("App", App.class)
.addInitParam("message", "Hello World Implementing Servelets")
.addMapping("/myservlet"));

DeploymentManager manager = defaultContainer().addDeployment(servletBuilder);
manager.deploy();

HttpHandler servletHandler = manager.start();
PathHandler path = Handlers.path(Handlers.redirect(MYAPP))
.addPrefixPath(MYAPP, servletHandler);
Undertow server = Undertow.builder()
.addHttpListener(8080, "localhost")
.setHandler(path)
.build();
server.start();
} catch (ServletException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}
}

如果您需要更多信息,请告诉我。

最佳答案

似乎在您的 pom.xml 上,类名不正确:

<mainClass>com.mastertheboss.undertow.ServeletEngine</mainClass>

应该是:

<mainClass>com.mastertheboss.undertow.ServletEngine</mainClass>

我说得对吗?

问候!

关于java - undertow 编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26641797/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com