首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >undertow中的编译错误

undertow中的编译错误
EN

Stack Overflow用户
提问于 2014-10-30 06:32:30
回答 1查看 989关注 0票数 1

我正在使用undertow开发一个new应用程序,并且是java的新手。运行ServeletEngine.java时出现错误。我查看了其他相关的帖子,但他们没有解决我的问题。请帮帮我。

Error: ERROR无法在下面的项目上执行目标编译(默认编译)- org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile :编译失败:编译失败:

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

我的pom.xml文件是:$ cat ~/undertow-server/pom.xml

代码语言:javascript
复制
<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>

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

代码语言:javascript
复制
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();
            }

    }
}

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

EN

回答 1

Stack Overflow用户

发布于 2014-10-30 07:48:29

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

代码语言:javascript
复制
<mainClass>com.mastertheboss.undertow.ServeletEngine</mainClass>

它应该是:

代码语言:javascript
复制
<mainClass>com.mastertheboss.undertow.ServletEngine</mainClass>

我说的对吗?

致以问候!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26641797

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档