0

我刚刚开始尝试在 Android 平台上运行的 I-Jetty 服务器。首先,我尝试使用来自 org.apache.maven.archetypes 的 Maven 原型“maven-archetype-webapp”创建一个简单的 Web 应用程序,我想在 I-Jetty 上对其进行测试。这会产生一个最小的 maven 项目,其中包含一个名为 index.jsp 的简单 jsp 文件,如下所示。

<html>
<body>
<h2>Hello!</h2>
</body>
</html>

当将此 web 应用程序导出为战争并部署到 I-Jetty 时,我从 I-Jetty 获得“不支持 jsp”。做了一些研究,我发现我必须预编译 JSP,因为 I-Jetty 没有 JSP 编译器。这就是问题所在。我正在尝试使用名为 jetty-jspc-maven-plugin 的预编译插件。我正在使用带有 m2e 插件的 Eclipse Kepler。

我已经搜索了不同的方法来处理预编译 jsps,结果是这个 pom;

<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>eggum</groupId>
<artifactId>odin</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>odin Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
    <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>3.8.1</version>
    <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
        <scope>provided</scope>
    </dependency>
</dependencies>
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>  
<build>
    <finalName>odin</finalName>    
    <pluginManagement>        
    <plugins>
        <plugin>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>jetty-jspc-maven-plugin</artifactId>
    <!--    <version>7.3.0.v20110203</version>   -->
            <version>9.1.0.M0</version>
            <extensions>true</extensions>
            <executions>
                <execution>
                    <id>jspc</id>
                    <goals>
                        <goal>jspc</goal>
                    </goals>
                    <configuration>
                        <includes>**/*.jsp</includes>
                        <webAppSourceDirectory>${basedir}/src/main/webapp</webAppSourceDirectory>  
                        <verbose>true</verbose>
                        <keepSources>true</keepSources>
                        <generatedClasses>${project.build.outputDirectory}/abc</generatedClasses>
                    </configuration>
                </execution>                
            </executions>
        </plugin>       
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <webXml>${basedir}/target/odin/WEB-INF/web.xml</webXml>
            </configuration>
        </plugin>
    </plugins>    
    </pluginManagement>
</build>
</project>

将项目作为 maven install 运行时,项目已成功构建,但似乎我的 jetty-jspc-maven-plugin 在构建中完全被忽略了:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building odin Maven Webapp 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ odin ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ odin ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ odin ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\EclipseKepler\odin\src\test\resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ odin ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-surefire-plugin:2.10:test (default-test) @ odin ---
[INFO] Surefire report directory: D:\EclipseKepler\odin\target\surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

[INFO] 
[INFO] --- maven-war-plugin:2.3:war (default-war) @ odin ---
[INFO] Packaging webapp
[INFO] Assembling webapp [odin] in [D:\EclipseKepler\odin\target\odin]
[INFO] Processing war project
[INFO] Copying webapp resources [D:\EclipseKepler\odin\src\main\webapp]
[INFO] Webapp assembled in [23 msecs]
[INFO] Building war: D:\EclipseKepler\odin\target\odin.war
[INFO] 
[INFO] --- maven-install-plugin:2.3.1:install (default-install) @ odin ---
[INFO] Installing D:\EclipseKepler\odin\target\odin.war to                     C:\Users\Dag\.m2\repository\eggum\odin\0.0.1-SNAPSHOT\odin-0.0.1-SNAPSHOT.war
[INFO] Installing D:\EclipseKepler\odin\pom.xml to C:\Users\Dag\.m2\repository\eggum\odin\0.0.1-    
SNAPSHOT\odin-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.581s
[INFO] Finished at: Mon Oct 14 11:34:27 CEST 2013
[INFO] Final Memory: 8M/155M
[INFO] ------------------------------------------------------------------------

我希望在这个过程中看起来像这样

[INFO] --- jetty-jspc-maven-plugin (jspc-compile) @ odin ---
[INFO] Compiling one jsp file...

但是在包含 jspc 插件之后,我什至没有得到错误代码或任何东西。作为 maven 的新手,我向一位经验丰富的 maven 用户寻求一些关于忽略 jetty-jspc-maven-plugin 的帮助。是构建周期问题吗?Eclipse 或 m2e 是否出于某种原因默默地忽略了这个插件?如您所见,maven-war-plugin 已执行,因此似乎并非所有插件都被忽略。

这是我在 Stackoverflow 上发布的第一个问题,所以如果我遗漏了关于这篇文章的任何信息,请原谅我。

4

1 回答 1

0

我发现了问题所在。这确实是一个生命周期问题,我通过在代码周围添加标签来隐藏它。我部分使用这篇文章找到了解决方案;

为什么我会收到“使用 GWT 的生命周期配置未涵盖的插件执行”错误?

于 2013-10-14T21:54:31.030 回答