在Eclipse 創建動態WEB 工程,在src 下 創建 config.xml:
1 <?xml version="1.0" encoding="UTF-8"?> 2 <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd"> 3 <configuration> 4 <environments default="development"> 5 <environment id="development"> 6 <transactionManager type="JDBC" /> 7 <!-- 配置數據庫連接信息 --> 8 <dataSource type="POOLED"> 9 <property name="driver" value="com.mysql.jdbc.Driver" /> 10 <property name="url" value="jdbc:mysql://localhost:3306/mybatis" /> 11 <property name="username" value="root" /> 12 <property name="password" value="123" /> 13 </dataSource> 14 </environment> 15 </environments> 16 17 </configuration>
提示Error: Content is not allowed in prolog
查看為DOM 解析xml error, 查看網上加入 dom4j.jar,refrensh並無效果;
// 解決辦法: 用記事本創建 config.xml ,選擇 ANSI 編碼,copy 到 src 下,不再提示Content is not allowed in prolog,
復制別人的xml文件內容時,行號也會被復制進去,注意去除,否則也會報錯
rg.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 2; 前言中不允許有內容