关于报错Unable to read XML

Caused by: org.hibernate.InvalidMappingException: Unable to read XML
	at org.hibernate.internal.util.xml.MappingReader.legacyReadMappingDocument(MappingReader.java:375)
	at org.hibernate.internal.util.xml.MappingReader.readMappingDocument(MappingReader.java:304)
	at org.hibernate.cfg.Configuration.add(Configuration.java:518)
	at org.hibernate.cfg.Configuration.add(Configuration.java:514)
	at org.hibernate.cfg.Configuration.add(Configuration.java:688)
	at org.hibernate.cfg.Configuration.addResource(Configuration.java:771)
	at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:2257)
	at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:2229)
	at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2209)
	at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2162)
	at org.hibernate.cfg.Configuration.configure(Configuration.java:2077)
	at com.fireangle.test.dao.SysUserDao.<clinit>(SysUserDao.java:20)
Caused by: org.dom4j.DocumentException: 3 字节的 UTF-8 序列的字节 3 无效。 Nested exception: 3 字节的 UTF-8 序列的字节 3 无效。
	at org.dom4j.io.SAXReader.read(SAXReader.java:484)
	at org.hibernate.internal.util.xml.MappingReader.legacyReadMappingDocument(MappingReader.java:325)
	... 11 more
Exception in thread "main" 

  • 把xml文件放到resources文件夹中
    在这里插入图片描述
    在这里插入图片描述
    在pom.xml里加入以下包
  <dependency>
            <groupId>org.dom4j</groupId>
            <artifactId>dom4j</artifactId>
            <version>2.1.1</version>
        </dependency>

<!--  这里是为了防止xml无法被打包而手动设置一下。 -->
    <build>
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
                <filtering>true</filtering>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/*.xml</include>
                    <include>**/*.properties</include>
                </includes>
            </resource>
        </resources>
    </build>
已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页