我正在使用Maven来构建春季项目。为了在本地测试它,我正在使用Jetty:Run目标。(Maven Jetty插件)
当我执行它时,我会得到:
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/class/db/在我的web.xml文件中,例如:
/web-inf/class/db/$ {app.server.context}
app.server.context在构建时被Maven替换(验证了)。
当我在Tomcat或Run Jetty中部署战争时没有问题:跑步我想问题是,从未包装资源运行时,Maven无法解决/Web-Inf/class/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>
..
..
好吧,我终于理解了这个问题。我以为Jetty有点搜索(Jetty:Run目标)
{workspace}/myApplication/src/main/webapp/web-inf/class/db
或
{workspace}/myapplication/target/myapplication/web-inf/class/db
web.xml config
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/classes/db/*Context_Tomcat.xml
/WEB-INF/classes/*Context.xml
</param-value>
</context-param>
但是,我有些意识到它正在搜索
{Workspace}/MyApplication/target/classes
是Eclipse项目输出文件夹&amp;没有包含DB文件夹(我在某种程度上将其排除在该输出文件夹中,战争已经包含它。)
所以我被排除在外,一切都很好。