• 报 java.lang.ExceptionInInitializerError 的常见解决方法


    报 java.lang.ExceptionInInitializerError 的常见解决方法

    0. 如果你是遇到这个问题?

    java.lang.ExceptionInInitializerError
    Caused by: org.apache.ibatis.exceptions.PersistenceException: 
    ### Error building SqlSession.
    ### The error may exist in com/xu/dao/UserMapper.xml
    ### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.io.IOException: Could not find resource com/xu/dao/UserMapper.xml
    	at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
    	at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:80)
    	at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:64)
    	at com.xu.utils.MybatisUtils.<clinit>(MybatisUtils.java:27)
    	... 23 more
    

    1. mybatis的配置文件是否有错

    不管是放在src/main/java还是src/main/resources下的目录,都是只需要写Java之后的的路径,如:

    mapper路径

    2. 检查是否放行静态资源

    需要在pom问价加入以下代码:

    <build>
            <resources>
                <resource>
                    <directory>src/main/resources</directory>
                    <includes>
                        <include>**/*.properties</include>
                        <include>**/*.xml</include>
                    </includes>
                    <filtering>true</filtering>
                </resource>
                <resource>
                    <directory>src/main/java</directory>
                    <includes>
                        <include>**/*.properties</include>
                        <include>**/*.xml</include>
                    </includes>
                    <filtering>true</filtering>
                </resource>
            </resources>
        </build>
    

    3.点击maven的Lifecycle中clean然后检查是否出现pom中配置问题

    如果点检clean出现以下问题,

    maven报错

    请检查pom文件,特别是以下几个标签是否有错:

    	<groupId>组ID</groupId>
        <artifactId>项目名</artifactId>
        <packaging>pom</packaging>
    
    刚刚参加工作,很有很多不懂不会的,发现错误,欢迎指正,谢谢!
  • 相关阅读:
    Node.js v0.10.1 稳定版发布
    PHP 5.5.0 Alpha6 发布
    DataNucleus Access Platform 3.2 正式版发布
    Swipe 2.0 发布,移动端滑动 JS 库
    Kamailio 4.0 发布,开源的SIP服务器
    PeerJS 0.1.7:一个用于浏览器内P2P的WebRTC封装器
    Apache Libcloud 0.12.3 发布
    IE 10将加强对Flash的支持
    JBoss Portlet Bridge 3.2.0.Beta2 发布
    如何在遗留代码基础上开发
  • 原文地址:https://www.cnblogs.com/xd-study/p/13714686.html
Copyright © 2020-2023  润新知