2013-10-14 81 views
0

我剛剛開始嘗試在Android平臺上運行的I-Jetty服務器。首先,我嘗試使用org.apache.maven.archetypes中的Maven原型「maven-archetype-webapp」創建一個簡單的Web應用程序,我想在I-Jetty上測試它。這導致了一個最小化的Maven項目,它帶有一個名爲index.jsp的簡單jsp文件,它看起來像這樣。JSP預編譯與m2e沒有響應

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

當將這個webapp作爲戰爭導出並部署到I-Jetty時,我從I-Jetty獲得「jsp不支持」。做了一些研究,我發現我必須預編譯JSP,因爲I-Jetty沒有JSP編譯器。這就是問題所在。我正在嘗試使用名爲jetty-jspc-maven-plugin的預編譯插件。我正在使用Eclipse Kepler和m2e插件。

我已經搜索了不同的方法來處理預編譯的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的安裝,該項目構建成功,但似乎我的碼頭,JSPC - Maven的插件在構建完全忽視:

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上的第一個問題,所以請原諒我,如果我缺少關於這篇文章的任何信息。

回答