Maven Jetty plugin daemon element not allowed here

后端 未结 2 1740
执念已碎
执念已碎 2021-01-18 11:33

I am trying to configure a project\'s pom.xml file. I want it to start Jetty server in testing phase. In order to do it I should add \"daemon\" element to Jetty plugin as I

相关标签:
2条回答
  • 2021-01-18 11:46

    It's actually a IntelliJ Idea's bug. It sometimes doesn't recognize some of configuration properties correctly. The plugin does have this property, so you don't really have other option than to just ignore the error in IDE. The plugin will work as expected.

    0 讨论(0)
  • 2021-01-18 11:54

    I know I am four years late, but I am investigating on the same issue.

    If you update Jetty's dependency to 10.0.0, the error is solved: daemon does not produce that error anymore.

    However, things get weird if you update to 11.0.0 (latest, on Maven Central):

    • daemon starts producing error again,
    • scanIntervalSeconds produces error too, whereas it previously never did.

    So, I made some researches.

    I suspect you took your code from using jetty and maven-failsafe-plugin.

    I read some of the Jetty 11 Programming Guide, and found this paragraph:

    Here is an example, which turns on scanning for changes every ten seconds, and sets the webapp context path to /test:

    <plugin>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-maven-plugin</artifactId>
      <version>{VERSION}</version>
      <configuration>
        <scan>10</scan>
        <webApp>
          <contextPath>/test</contextPath>
        </webApp>
      </configuration>
    </plugin>
    

    Also, I found this other paragraph:

    Here’s an example of using the pre-integration-test and post-integration-test Maven build phases to trigger the execution and termination of Jetty:

    <plugin>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-maven-plugin</artifactId>
      <version>{VERSION}</version>
      <configuration>
        <scan>10</scan>
        <stopKey>foo</stopKey>
        <stopPort>9999</stopPort>
      </configuration>
      <executions>
        <execution>
          <id>start-jetty</id>
          <phase>pre-integration-test</phase>
          <goals>
            <goal>start</goal>
          </goals>
          <configuration>
            <scan>0</scan>
          </configuration>
        </execution>
        <execution>
          <id>stop-jetty</id>
          <phase>post-integration-test</phase>
           <goals>
             <goal>stop</goal>
           </goals>
         </execution>
      </executions>
    </plugin>
    

    Thus, I replaced the scanIntervalSeconds occurrences with scan. As result of this, IntelliJ didn't signal any error for the first occurrence anymore. However, the second occurrence still produces error.

    As far as daemon is concerned...

    On the old Jetty 9 documentation:

    For example, you can configure the plugin to start your webapp at the beginning of your unit tests and stop at the end. To do this, you need to set up a couple of execution scenarios for the Jetty plugin. You use the pre-integration-test and post-integration-test Maven build phases to trigger the execution and termination of Jetty:

    <plugin>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-maven-plugin</artifactId>
      <version>{VERSION}</version>
      <configuration>
        <scanIntervalSeconds>10</scanIntervalSeconds>
        <stopKey>foo</stopKey>
        <stopPort>9999</stopPort>
      </configuration>
      <executions>
        <execution>
          <id>start-jetty</id>
          <phase>pre-integration-test</phase>
          <goals>
            <goal>start</goal>
          </goals>
          <configuration>
            <scanIntervalSeconds>0</scanIntervalSeconds>
          </configuration>
        </execution>
        <execution>
          <id>stop-jetty</id>
          <phase>post-integration-test</phase>
           <goals>
             <goal>stop</goal>
           </goals>
         </execution>
      </executions>
    </plugin>
    

    The daemon is not even mentioned here. So, it is possible that Failsafe's documentation has an error, and daemon is not really needed.

    To conclude:

    • I have no clue why daemon worked on 10 and doesn't anymore in 11.
    • It seems it is not even necessary...
    0 讨论(0)
提交回复
热议问题