【问题标题】:I follow this maven-glassfish-plugin example but error message,why?我按照这个 maven-glassfish-plugin 示例但是错误消息,为什么?
【发布时间】:2011-03-08 14:27:21
【问题描述】:

昨天,我阅读了 glassfish 嵌入示例,这个地址是: http://weblogs.java.net/blog/arungupta/archive/2008/11/totd_56_simple.html

但我运行命令 glassfish:run 时出现错误消息

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>

为什么?请给我一个完整的 pom.xml 示例,谢谢。

【问题讨论】:

    标签: java maven-2 jakarta-ee glassfish


    【解决方案1】:

    正如我在previous answer 中所怀疑的那样,您正在使用的东西和您正在遵循的教程已经过时(GlassFish v3 Prelude 早于 GlassFish v3,后者已于 2009 年 12 月发布并随着最近发布的 GlassFish 3.0 更新。 1) 从那时起,Maven 插件之类的东西发生了变化。

    所以,虽然应该可以让事情正常运行,但我不会花时间尝试 :) 相反,这里是 ma​​ven-embedded-glassfish- 的最新(最小)配置插件

    <project>
      ...
      <pluginRepositories>
        <pluginRepository>
          <id>m.g.o-groups-glassfish</id>
          <url>http://maven.glassfish.org/content/groups/glassfish</url>
        </pluginRepository>
      </pluginRepositories>
      ...
      <build>
        <plugins>
          <plugin>
            <groupId>org.glassfish</groupId>
            <artifactId>maven-embedded-glassfish-plugin</artifactId>
            <version>3.0.1</version>
            <configuration>
              <app>${project.build.directory}/${build.finalName}.war</app>
              <autoDelete>true</autoDelete>
              <port>8080</port>
              <contextRoot>test</contextRoot>
            </configuration>
          </plugin>
          ...
        </plugins>
        ...
      </build>
    </project>
    

    然后运行:

    mvn embedded-glassfish:run
    

    然后将浏览器指向http://localhost:8080/test

    【讨论】:

    【解决方案2】:

    这是用于运行 Embedded 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/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多