【问题标题】:Build waits at Jetty start when running integration tests运行集成测试时在 Jetty 启动时构建等待
【发布时间】:2015-12-26 00:09:50
【问题描述】:

我正在尝试运行一些集成/验收测试。

我只想在传递环境变量时运行这些测试,所以我使用以下命令:

mvn clean install -Denv="acceptance"

但是构建停止在

2015-09-28 18:56:19.273:INFO:oejsh.ContextHandler:main: Started o.e.j.m.p.JettyWebAppContext@4bbc9862{/,file:///home/stephane/dev/java/projects/kahoot-rest/src/main/webapp/,AVAILABLE}{file:///home/stephane/dev/java/projects/kahoot-rest/src/main/webapp/}
2015-09-28 18:56:19.419:INFO:oejs.ServerConnector:main: Started ServerConnector@26b4acf4{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
2015-09-28 18:56:19.423:INFO:oejs.Server:main: Started @171829ms
[INFO] Started Jetty Server

我使用的是 Java 1.8。

我的 pom.xml 文件:

    <profile>
        <id>acceptance</id>
        <activation>
            <property>
                <name>env</name>
                <value>acceptance</value>
            </property>
        </activation>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>failsafe-maven-plugin</artifactId>
                    <version>2.4.3-alpha-1</version>
                    <configuration>
                        <includes>
                            <include>**/acceptance/*.java</include>
                        </includes>
                        <excludes>
                            <exclude>**/*$*</exclude>
                        </excludes>
                    </configuration>
                    <executions>
                        <execution>
                            <goals>
                                <goal>integration-test</goal>
                                <goal>verify</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.eclipse.jetty</groupId>
                    <artifactId>jetty-maven-plugin</artifactId>
                    <version>9.3.4.RC0</version>
                    <executions>
                        <execution>
                            <id>start-jetty</id>
                            <phase>pre-integration-test</phase>
                            <goals>
                                <goal>run</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>stop-jetty</id>
                            <phase>post-integration-test</phase>
                            <goals>
                                <goal>stop</goal>
                            </goals>
                            <configuration>
                                <stopKey>stop</stopKey>
                                <stopPort>8081</stopPort>
                            </configuration>
                        </execution>
                    </executions>
                    <configuration>
                        <scanIntervalSeconds>10</scanIntervalSeconds>
                        <connectors>
                            <connector implementation="org.eclipse.jetty.nio.SelectChannelConnector">
                                <port>8080</port>
                                <maxIdleTime>60000</maxIdleTime>
                            </connector>
                        </connectors>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>

【问题讨论】:

    标签: maven maven-jetty-plugin


    【解决方案1】:

    改变

    <goal>run</goal>
    

    <goal>start</goal>
    

    并添加守护进程选项

    <configuration>
        <daemon>true</daemon>
    </configuration>
    

    【讨论】:

    • 您会知道为什么在使用我的应用程序时 AngularJS 使用 localhost:8080/kahoot-rest/api url 访问 REST 端点,但是在 Jetty 下的验收测试中执行 REST 端点时,它们位于localhost:8080/api 网址?
    • 我明白了。我只需要在 Jetty 服务器的配置中添加一个上下文: /kahoot-rest
    猜你喜欢
    • 2016-03-24
    • 2016-02-29
    • 1970-01-01
    • 2013-05-17
    • 1970-01-01
    • 2015-05-13
    • 2021-12-03
    • 2012-11-14
    • 2012-03-03
    相关资源
    最近更新 更多