【问题标题】:Maven and webstart project how to test using jetty?Maven 和 webstart 项目如何使用 jetty 进行测试?
【发布时间】:2013-05-16 12:54:43
【问题描述】:

我有一个 Maven 项目,我已经集成了 webstart-maven-plugin。 jnlp 被生成,我想通过将它部署到码头来测试它,但还没有找到任何码头目标来实现这一点。有没有一种自动化的方法来测试 jnlp?

【问题讨论】:

    标签: java maven java-web-start maven-jetty-plugin


    【解决方案1】:

    我一直在使用webstart-maven-plugin,直到我意识到它只是填充了一个 jnlp 模板并复制了 jar 文件。

    现在,我使用静态 jnlp(存储在 src/main/webapp/applet)和 maven-dependency-plugin 来复制 jar:

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>applet-copy</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>applet.group.id</groupId>
                                    <artifactId>applet-artifact-id</artifactId>
                                    <version>x.y.z</version>
                                    <type>jar</type>
                                    <destFileName>applet.jar</destFileName>
                                </artifactItem>
                            </artifactItems>
                            <outputDirectory>${project.build.directory}/web-resources/applet</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
    

    它实际上将小程序复制到target/web-resources/applet。然后我只需要将这个目录作为网络资源添加到jetty-maven-plugin:

            <plugin>
                <groupId>org.mortbay.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <version>8.1.9.v20130131</version>
                <configuration>
                    <stopKey>STOP</stopKey>
                    <stopPort>9999</stopPort>
                    <scanIntervalSeconds>5</scanIntervalSeconds>
                    <webAppConfig>
                        <contextPath>/${project.artifactId}</contextPath>
                        <resourceBases>
                            <resourceBase>${project.build.directory}/web-resources</resourceBase>
                        </resourceBases>
                    </webAppConfig>
                </configuration>
            </plugin>
    

    并将其添加到战争中:

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.2</version>
                <configuration>
                    <webResources>
                        <resource>
                            <directory>${project.build.directory}/web-resources</directory>
                        </resource>
                    </webResources>
                </configuration>
            </plugin>
    

    希望对你有帮助。

    顺便可以找到更多关于jetty-maven-plugin配置on this page的信息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-11-18
      • 2011-03-29
      • 2017-08-08
      • 1970-01-01
      • 1970-01-01
      • 2011-01-30
      • 2019-10-20
      • 2020-06-16
      相关资源
      最近更新 更多