Java 扩展类路径和Tomcat插件
我目前正在工作的项目是一个标准的web应用程序,希望用嵌入式tomcat(mvn tomcat7:run)启动它。在META-INF/context.xml中有一个条目Java 扩展类路径和Tomcat插件,java,maven,tomcat7,Java,Maven,Tomcat7,我目前正在工作的项目是一个标准的web应用程序,希望用嵌入式tomcat(mvn tomcat7:run)启动它。在META-INF/context.xml中有一个条目 <Loader className="org.apache.catalina.loader.VirtualWebappLoader" virtualClasspath="${home}/lib"/> 被扔了 在context.xml中扩展类路径时,有没有办法让嵌入tomcat的tomcat插件工
<Loader className="org.apache.catalina.loader.VirtualWebappLoader"
virtualClasspath="${home}/lib"/>
被扔了
在context.xml中扩展类路径时,有没有办法让嵌入tomcat的tomcat插件工作?这个问题的答案是将tomcat插件设置为使用独立于maven的类加载器。这是通过将插件的
useSpeparateToMcCatClassLoader
参数设置为true来实现的。这可以在Tomcat插件配置中完成:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<configuration>
<contextReloadable>true</contextReloadable>
<useSeparateTomcatClassLoader>true</useSeparateTomcatClassLoader>
</configuration>
</plugin>
请参阅:这个问题的答案是将Tomcat插件设置为使用独立于maven的类加载器。这是通过将插件的
useSpeparateToMcCatClassLoader
参数设置为true来实现的。这可以在Tomcat插件配置中完成:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<configuration>
<contextReloadable>true</contextReloadable>
<useSeparateTomcatClassLoader>true</useSeparateTomcatClassLoader>
</configuration>
</plugin>
参见:问题;在您指向的虚拟目录中是否有报告为“ClassNotFound”的类?是否定义了${home}?另外,如果您只在virtualClasspath中声明了目录,那么这些类将在分解的目录层次结构中找到;如果在${home}/lib中有几个jar文件,那么应该将每个jar作为单独的virtualClasspath元素列出。当运行mvn tomcat7:run war(以及当我生成war文件并将其复制到现有的tomcat时),webapp可以正常工作。只有在使用嵌入式tomcat时才会发生异常。未找到的类是Catalina类。{$home}已定义,我已分解目录层次结构;在您指向的虚拟目录中是否有报告为“ClassNotFound”的类?是否定义了${home}?另外,如果您只在virtualClasspath中声明了目录,那么这些类将在分解的目录层次结构中找到;如果在${home}/lib中有几个jar文件,那么应该将每个jar作为单独的virtualClasspath元素列出。当运行mvn tomcat7:run war(以及当我生成war文件并将其复制到现有的tomcat时),webapp可以正常工作。只有在使用嵌入式tomcat时才会发生异常。未找到的类是Catalina类。{$home}已定义,我已分解了目录层次结构。
mvn tomcat7:run -Dtomcat.useSeparateTomcatClassLoader=true