Maven Jetty运行JNDI配置

Sua*_*Nti 3 spring jndi maven maven-jetty-plugin

我的项目结构如下所示:

parent POM 
|-- app-core
|-- app-model
|-- app-services
`-- app-web
Run Code Online (Sandbox Code Playgroud)

在我pom.xmlapp-web:

<plugin>
    <groupId>org.mortbay.jetty</groupId>
    <artifactId>maven-jetty-plugin</artifactId>
    <version>6.1.10</version>
    <configuration>
    <webDefaultXml>src/test/resources/webdefault.xml</webDefaultXml>
    </configuration>
 </plugin>
Run Code Online (Sandbox Code Playgroud)

热部署正常运行并且没有问题 mvn jetty:run

问题:app-core使用spring如何 在这个多模块层次结构中为Jetty maven插件配置这个JNDI,这应该可以在app-core模块中访问

更新:

像这样添加了pom.xml

  <plugin>
    <groupId>org.mortbay.jetty</groupId>
    <artifactId>maven-jetty-plugin</artifactId>
    <version>6.1.10</version>
    <configuration>
    <webDefaultXml>src/main/resources/webdefault.xml</webDefaultXml>
    <jettyConfig>src/main/resources/jetty.xml</jettyConfig>
    </configuration>
  </plugin>
Run Code Online (Sandbox Code Playgroud)

我的jetty.xml看起来像这样:

  <Configure class="org.mortbay.jetty.webapp.WebAppContext">
<New id="icatDB" class="org.mortbay.jetty.plus.naming.Resource">
    <Arg>jdbc/testDB</Arg>
    <Arg>
<New class="net.sourceforge.jtds.jdbcx.JtdsDataSource">
    <Set name="serverName">localhost</Set>
    <Set name="databaseName">test</Set>
    <Set name="user">sa</Set>
    <Set name="password"></Set>
</New>
</Arg>
</New>
 </Configure>
Run Code Online (Sandbox Code Playgroud)

之后当我运行mvn jetty时:运行我得到这个错误

Failure: Object is not of type class org.mortbay.jetty.webapp.WebAppContext
Run Code Online (Sandbox Code Playgroud)

Sua*_*Nti 6

好的,这对我有用:

我需要使用jettyEnvXml而不是jettyConfig.

 <plugin>
    <groupId>org.mortbay.jetty</groupId>
    <artifactId>maven-jetty-plugin</artifactId>
    <version>6.1.10</version>
    <configuration>
    <webDefaultXml>src/main/resources/webdefault.xml</webDefaultXml>
    <jettyEnvXml>src/main/resources/jetty.xml</jettyEnvXml> 
    </configuration>
  </plugin>
Run Code Online (Sandbox Code Playgroud)