首页 / 操作系统 / Linux / Maven的Jetty插件提示No Transaction manager found导致启动慢的解决方法
在使用maven开发web项目极大地方便了jar包的依赖,在测试时也可以集成Servlet容器,从启动速度和量级上看,Jetty无疑是不二选择,然而从8.x开始,如果你的web项目中不包含数据库访问(或者说没有事务管理器)的话,在其启动时会提示找不到事务管理器,输出信息如下:oejpw.PlusConfiguration:No Transaction manager found - if your webapp requires one, please configure one.而且启动过程会暂停十几秒,在反复调试代码时很浪费时间,经过多天在网上搜索资料,终于找到了解决办法。首先是pom.xml中关于插件的配置:<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.15.v20140411</version>
<configuration>
<stopKey>stop</stopKey>
<stopPort>9999</stopPort>
<scanIntervalSeconds>1</scanIntervalSeconds>
<contextXml>${project.basedir}/src/main/resources/jetty-context.xml</contextXml>
<webApp>
<contextPath>/</contextPath>
</webApp>
<connectors>
<connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
<port>80</port>
<maxIdleTime>60000</maxIdleTime>
</connector>
</connectors>
</configuration>
</plugin>重要的是加上<contextXml>配置,我们要对jetty的服务器属性进行配置。本例中把配置文件放到了/src/main/resources中(如果你不希望打包时带上这个文件,可以放到/src/test/resources中,改下配置即可),文件名为:jetty-context.xml。接下来是配置文件:<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Call name="setAttribute">
<Arg>org.eclipse.jetty.server.webapp.WebInfIncludeJarPattern</Arg>
<Arg>.*/.*jsp-api-[^/].jar$|./.*jsp-[^/].jar$|./.*taglibs[^/]*.jar$</Arg>
</Call>
</Configure>至于为什么这样配置,还没有进行深入研究。使用Jetty作为嵌入式服务器 http://www.linuxidc.com/Linux/2013-07/86983.htmJetty 源码分析 http://www.linuxidc.com/Linux/2013-10/90986.htmJetty安装学习并展示 http://www.linuxidc.com/Linux/2014-05/101993.htmJetty在Eclipse中的安装 http://www.linuxidc.com/Linux/2013-10/90991.htmLinux(RedHat 5.8)下 安装Jetty 部署 使用 http://www.linuxidc.com/Linux/2014-10/108342.htmJetty 的详细介绍:请点这里
Jetty 的下载地址:请点这里本文永久更新链接地址:http://www.linuxidc.com/Linux/2015-01/111150.htm