2010-06-26 26 views
1

昨天,我讀了GlassFish嵌入例如這個地址是: http://weblogs.java.net/blog/arungupta/archive/2008/11/totd_56_simple.html我遵循這個maven-glassfish-plugin的例子,但錯誤消息,爲什麼?

,但我在運行命令的GlassFish:運行了錯誤信息

No plugin found for prefix 'glassfish' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories 

我的pom.xml的是

<dependencies> 
    <dependency> 
     <groupId>org.glassfish.distributions</groupId> 
     <artifactId>web-all</artifactId> 
     <version>10.0-SNAPSHOT</version> 
     <type>jar</type> 
     <classifier>build</classifier> 
     <scope>compile</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.glassfish.embedded</groupId> 
     <artifactId>glassfish-embedded-all</artifactId> 
     <version>3.0-Prelude-SNAPSHOT</version> 
     <type>jar</type> 
     <scope>compile</scope> 
    </dependency> 
</dependencies> 

<build> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <version>2.3.1</version> 
      <configuration> 
       <source>1.6</source> 
       <target>1.6</target> 
       <encoding>utf-8</encoding> 
      </configuration> 
     </plugin> 

     <plugin> 
      <groupId>org.glassfish.maven.plugin</groupId> 
      <artifactId>maven-glassfish-plugin</artifactId> 

     </plugin> 
    </plugins> 
    <finalName>SSH2Maven</finalName> 
</build> 
<pluginRepositories> 
    <pluginRepository> 
     <id>ocean glassfish</id> 
     <url>http://maven.ocean.net.au/snapshot</url> 
     <releases> 
      <enabled>false</enabled> 
      <updatePolicy>never</updatePolicy> 
     </releases> 
     <snapshots> 
      <enabled>true</enabled> 
      <updatePolicy>always</updatePolicy> 
     </snapshots> 
    </pluginRepository> 
</pluginRepositories> 
<repositories> 
    <repository> 
     <id>glassfish repo</id> 
     <url>http://maven.glassfish.org/content/groups/glassfish</url> 
    </repository> 
</repositories> 

爲什麼? Plz給我一個完整的pom.xml例子,thx。

回答

2

正如我在previous answer中懷疑的那樣,您正在使用的內容和您正在使用的教程已過時(GlassFish v3 Prelude在GlassFish v3之前,該版本已於2009年12月發佈,並且最新版本的GlassFish 3.0.1 )以及像Maven插件之類的東西從那以後發生了變化。

因此,雖然應該可以使事情有效,但我不會花費一些時間嘗試:)相反,這裏是最新的(最小)配置,用於maven-embedded-glassfish-plugin

​​

然後運行:

mvn embedded-glassfish:run 

而且在http://localhost:8080/test指向您的瀏覽器。

+0

哦,我讀了「來設置你的Maven環境(http://docs.sun.com/app/docs/doc/821-1208/gihus?l=en&a=view)「在昨天,但我搜索谷歌都是例子。所以我想嘗試一下這個例子。非常感謝你的回答。 – EdwardLau 2010-06-26 14:36:22

0

下面是最新的<插件>運行嵌入式GlassFish的4.0:

<plugin> 
      <groupId>org.glassfish.embedded</groupId> 
      <artifactId>maven-embedded-glassfish-plugin</artifactId> 
      <version>4.0</version> 
      <configuration> 
       <app>target/${project.artifactId}.war</app> 
       <port>8080</port> 
       <ports> 
        <https-listener>8181</https-listener> 
       </ports>  
      </configuration> 
      <dependencies> 
       <dependency> 
        <groupId>org.glassfish.main.common</groupId> 
        <artifactId>simple-glassfish-api</artifactId> 
        <version>4.0</version> 
       </dependency>      
       <dependency> 
        <groupId>org.glassfish.main.extras</groupId> 
        <artifactId>glassfish-embedded-all</artifactId> 
        <version>4.0</version> 
       </dependency> 
      </dependencies> 
      <executions> 
       <execution> 
        <id>start</id> 
        <phase>integration-test</phase> 
        <goals> 
         <goal>start</goal> 
         <goal>deploy</goal> 
        </goals> 
       </execution> 
       <execution> 
        <id>stop</id> 
        <phase>post-integration-test</phase> 
        <goals> 
         <goal>undeploy</goal> 
         <goal>stop</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 

看到工作示例:

https://github.com/arun-gupta/javaee7-samples/