`
eimhee
  • 浏览: 2112308 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

maven的jetty插件提示No Transaction manager found导致启动慢的解决方法

 
阅读更多

 

参考 http://jira.codehaus.org/browse/JETTY-1503

写道
Don't forget you can use the following to specify which jars to scan in your webapp:

org.eclipse.jetty.server.webapp.WebInfIncludeJarPattern
eg
./.*foo-api-[^/]\.jar$|./.*bar-[^/]\.jar$|./.*wibble[^/]\.jar$

 

在使用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.16.v20140903</version>
    <configuration>
    <jettyXml>conf/jetty.xml,conf/jetty-ssl.xml</jettyXml>
    <contextXml>conf/jetty-contexts.xml</contextXml>
    <scanIntervalSeconds>10</scanIntervalSeconds>
     <webApp>
      <contextPath>/</contextPath>
    </webApp>
  </configuration>
</plugin>

 

重要的是加上

<contextXml>

配置,我们要对jetty的服务器属性进行配置。本例中把配置文件放到了/src/main/resources中(如果你不希望打包时带上这个文件,可 以放到/src/test/resources中,改下配置即可),文件名为:jetty-context.xml。接下来是配置文件:

 

<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">

<!-- =============================================================== -->
<!-- Add a ContextProvider to the deployment manager                 -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- This scans the webapps directory for war files and directories  -->
<!-- to deploy.                                                      -->
<!-- This configuration must be used with jetty-deploy.xml, which    -->
<!-- creates the deployment manager instance                         -->
<!-- =============================================================== -->
<Configure id="Server" 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>  

 

 

http://laravel.iteye.com/

 

0
0
分享到:
评论
1 楼 xiaosong0112 2015-12-30  
您好,请问为什么要这样设置呢,原理是什么?在网上很多转帖都没有说。

相关推荐

Global site tag (gtag.js) - Google Analytics