我似乎无法让Maven Glassfish插件在我的生活中工作:
<project>
...
<pluginRepositories>
<pluginRepository>
<id>glassfish-repository</id>
<name>Java.net Repository for Glassfish</name>
<url>http://download.java.net/maven/glassfish</url>
<layout>default</layout>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
...
<build>
<plugins>
<plugin>
<groupId>org.glassfish</groupId>
<artifactId>maven-embedded-glassfish-plugin</artifactId>
<version>3.0</version>
<configuration>
<goalPrefix>glassfish</goalPrefix>
<app>${artifactId}.war</app>
<contextRoot>${context.root}</contextRoot>
<port>${http.port}</port>
</configuration>
</plugin>
...
</plugins>
</build>
</project>
当我运行mvn glassfish:run
时,它正在寻找一个不同的插件而无法找到它:
[INFO] The plugin 'org.apache.maven.plugins:maven-glassfish-plugin' does not exist or no valid version could be found
有什么想法吗?
答案 0 :(得分:13)
你没有调用正确的插件。它应该是:
mvn embedded-glassfish:run
实际上,我正在使用它:(使用您声明的相同插件存储库):
<plugins>
<plugin>
<groupId>org.glassfish</groupId>
<artifactId>maven-embedded-glassfish-plugin</artifactId>
<version>3.0</version>
<configuration>
<goalPrefix>glassfish</goalPrefix>
<app>target/test.war</app>
<port>8080</port>
<contextRoot>test</contextRoot>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
更新:以防万一,此插件的完全限定名称为:
mvn org.glassfish:maven-embedded-glassfish-plugin:3.0:run
但使用短名称对我有用。
答案 1 :(得分:3)
@Walter White(不能/不知道如何回复你的评论所以我正在回答): 我读过分散的WAR是not fully supported by embedded GlassFish v3。
就我个人而言,我正在焦急地等待v3.1的Timer和MessageDriven支持。希望也包括Web服务支持。有没有人碰巧有关于v3.1的ETA的线索?
PS:mvn org.glassfish:maven-embedded-glassfish-plugin:3.0:run
适合我。现在将它连接到正确的maven集成测试生命周期。
答案 2 :(得分:0)
这个问题的结果是2个不同的maven-glassfish插件同名存在。尝试使用
mvn org.glassfish:maven-glassfish-plugin:run
您可以找到此问题的详细说明here。
答案 3 :(得分:0)
请参阅github工作示例
mvn package embedded-glassfish:运行
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.glassfish.embedded</groupId>
<artifactId>maven-embedded-glassfish-plugin</artifactId>
<version>3.1.2.2</version>
<configuration>
<app>target/${project.artifactId}-${project.version}</app>
<port>8080</port>
<contextRoot>${project.artifactId}</contextRoot>
</configuration>
<dependencies>
<dependency>
<groupId>org.glassfish.main</groupId>
<artifactId>simple-glassfish-api</artifactId>
<version>4.0-b79</version>
</dependency>
<dependency>
<groupId>org.glassfish.main.extras</groupId>
<artifactId>glassfish-embedded-all</artifactId>
<version>4.0-b83</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
<pluginRepositories>
<pluginRepository>
<id>maven.java.net</id>
<name>Java.net Repository for Maven</name>
<url>https://maven.java.net/content/groups/promoted/</url>
</pluginRepository>
<pluginRepository>
<id>maven2-repository.dev.java.net</id>
<name>Java.net Repository for Maven</name>
<url>http://download.java.net/maven/glassfish/</url>
</pluginRepository>
</pluginRepositories>