【发布时间】:2014-04-19 13:42:19
【问题描述】:
我正在使用 Maven 构建一个 Spring 项目。 为了在本地测试它,我使用 jetty:run 目标。 (maven 码头插件)
当我执行它时,我得到:
Caused by:
java.io.FileNotFoundException: ServletContext resource [/WEB-INF/classes/db/]
cannot be resolved to URL because it does not exist
at
org.springframework.web.context.support.ServletContextResource.getURL
(ServletContextResource.java:154)
/WEB-INF/classes/db/ 在我的 WEB.xml 文件中,像这样:
/WEB-INF/classes/db/${app.server.context}
app.server.context 在构建时被 maven 替换(验证)。
当我在tomcat中部署我的war或运行jetty时没有问题:run-exploded 我想问题是从未打包的资源运行时,maven 无法解析 /WEB-INF/classes/db/ 。我怎样才能让它解决它?
这是我的码头插件的 Maven 配置:
..
..
<plugin>
<!-- http://wiki.eclipse.org/Jetty/Feature/Jetty_Maven_Plugin -->
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty.version}</version>
<configuration>
<!-- <scanIntervalSeconds>10</scanIntervalSeconds> -->
<classesDirectory>${basedir}/target/classes</classesDirectory>
<scanIntervalSeconds>10</scanIntervalSeconds>
<war>${basedir}/target</war>
<webAppConfig>
<descriptor>${basedir}/target/MyApplication/WEB-INF/web.xml</descriptor>
<contextPath>${application.contextpath}</contextPath>
<allowDuplicateFragmentNames>true</allowDuplicateFragmentNames>
</webAppConfig>
<connectors>
<connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
<port>${application.port}</port>
</connector>
</connectors>
<requestLog implementation="org.eclipse.jetty.server.NCSARequestLog">
<filename>${project.build.directory}/jetty-yyyy_mm_dd-request.log
</filename>
<retainDays>3</retainDays>
<append>true</append>
<extended>false</extended>
<logTimeZone>GMT</logTimeZone>
</requestLog>
</configuration>
</plugin>
..
..
【问题讨论】: