2010-06-26 64 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/