我正在開發一個使用高級管道的web應用程序,而且對於java來說相當新穎。運行ServeletEngine.java時出現錯誤。我查了其他相關帖子,但他們還沒有解決我的查詢。請幫幫我。編譯失敗:編譯失敗:高級編譯錯誤
錯誤:[錯誤]無法執行目標org.apache.maven.plugins:maven-compiler-plugin:2.3.2:編譯(default-compile)項目undertow-server:編譯失敗:編譯失敗:
我的目錄結構: 〜/暗潮服務器/ src目錄/主/ JAVA/COM/mastertheboss /暗潮/ ServeletEngine.java
我pom.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/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>
Servelet Engine.java處於: $ cat〜/ undertow-server/src/main/java/com/mastertheboss/undertow/ServletEngine.java package com.mastertheboss.undertow; import io.undertow.Undertow; import io.undertow.server。*; import 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();
}
}
}
如果您需要更多信息,請讓我知道。
哪個版本的Java? – 2014-10-29 23:07:09
java版本「1.8.0_25」 – pm2014 2014-10-30 00:14:49
呃...我不會打瞌睡。我複製粘貼你的兩個文件,修復mainClass名稱並添加一個簡單的MySessionListener類和一個簡單的App servlet。你猜怎麼了 ?它起作用,當我啓動'mvn compile exec:java'時。 – 2014-10-30 00:24:55