1

undertow を使用して webapp を開発していますが、Java は初めてです。ServeletEngine.java の実行中にエラーが発生します。他の関連する投稿を確認しましたが、クエリが解決されていません。私を助けてください。

エラー: [エラー] プロジェクト undertow-server で目標 org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) を実行できませんでした: コンパイル エラー: コンパイル エラー:

私のディレクトリ構造は次のとおりです: ~/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>

$ cat ~/undertow-server/src/main/java/com/mastertheboss/undertow/ServletEngine.java パッケージ 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();
            }

    }
}

さらに情報が必要な場合はお知らせください。

4

1 に答える 1

0

pom.xml で、クラス名が間違っているようです:

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

そのはず:

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

私は正しいですか?

よろしく!

于 2014-10-29T23:48:28.637 に答える