zoukankan      html  css  js  c++  java
  • 解决 maven构建的web项目无法在外部Tomcat中运行的问题

    今天遇到 maven构建的web项目在idea中能正常运行但打成war包后在外部容器tomcat中无法运行的问题。总结一下遇到的问题:
    第一个问题:项目结构不对
    我的项目结构:

    一般maven项目是:
    明显少了一层 java maven在打包时会以src/main/java 作为package的sources root 但我的项目中没有这个目录就会导致 在spring的配置文件中配置的包路径 全都不正确;贴一个报错信息
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'job' defined in class path resource [applicationContext.xml]: Cannot resolve reference to bean 'IapIosTaskSer' while setting bean property 'targetObject';
    所以后来在项目中添加了java这个文件夹,然后把原来的com文件夹移动到java下面;
    题外说一句:我用的IDE是idea那么我在idea中是如何把项目跑起来的了。
    idea是可以指定sources root 的,指定后的就可以根据路径找到类了。
    第二个问题:mapper.xml没打包
    打成war后mapper.xml全都不见了,所以在调用mapper层方法的时候,都要报错。解决办法在网上找了个办法;在pom.xml中添加了这段代码。
    <build>
      <resources>
        <resource>
          <directory>src/main/java</directory>
          <includes>
            <include>**/*.xml </include>
          </includes>
        </resource>
        <resource>
          <directory>src/main/resources</directory>
          <includes>
            <include>**/*.* </include>
          </includes>
        </resource>
    
        <resource>
          <directory>src/main/webapp/WEB-INF</directory>
          <includes>
            <include>*.xml </include>
            <include>*.properties </include>
          </includes>
        </resource>
      </resources>
    </build>
    

      

    解决这2个问题后就顺利的在外部的tomcat中运行起来了
  • 相关阅读:
    JS站点
    1011 World Cup Betting (20分)
    1007 Maximum Subsequence Sum (25分)(动态规划DP)
    1006 Sign In and Sign Out (25分)
    1005 Spell It Right (20分)
    1004 Counting Leaves (30分)(DFS)
    1003 Emergency (25分)(Dijkstra算法)
    1002 A+B for Polynomials (25分)
    1001 A+B Format (20分)
    canvas
  • 原文地址:https://www.cnblogs.com/lxoy/p/7412611.html
Copyright © 2011-2022 走看看