首页 新闻 会员 周边

试着用ssm做,结果这个generatorConfig.xml报错

0
悬赏园豆:10 [已解决问题] 解决于 2016-05-30 17:20

就是这个错误刚开始学...

然后下面给上代码

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <!DOCTYPE generatorConfiguration
 3         PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
 4         "-://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
 5 
 6 <generatorConfiguration>
 7     <!--数据库驱动jar -->
 8     <classPathEntry location="E:\njfu\ssm_test\WebContent\WEB-INF\lib\mysql-connector-java-5.1.31.jar" />
 9  
10     <context id="DB2Tables" targetRuntime="MyBatis3">
11         <!--去除注释 (true好像不起作用) -->
12         <commentGenerator >  
13             <property name="suppressAllComments" value="true"/><!-- 是否取消注释 -->  
14             <property name="suppressDate" value="true" /> <!-- 是否生成注释代时间戳-->  
15         </commentGenerator> 
16  
17         <!--数据库连接 -->
18 <!--         <jdbcConnection driverClass="com.mysql.jdbc.Driver"
19                         connectionURL="jdbc:mysql://222.186.44.11:3306/njfu"
20                         userId="root"
21                         password="yammy">
22         </jdbcConnection> -->
23         
24         
25         <jdbcConnection driverClass="com.mysql.jdbc.Driver"
26                         connectionURL="jdbc:mysql://127.0.0.1:3306/njfu"
27                         userId="root"
28                         password="root">
29         </jdbcConnection>
30         <!--默认false
31            Java type resolver will always use java.math.BigDecimal if the database column is of type DECIMAL or NUMERIC.
32          -->
33         <javaTypeResolver >
34             <property name="forceBigDecimals" value="false" />
35         </javaTypeResolver>
36  
37         <!--生成实体类 指定包名 以及生成的地址 (可以自定义地址,但是路径不存在不会自动创建  使用Maven生成在target目录下,会自动创建) -->
38         <javaModelGenerator targetPackage="user_information.vo" targetProject="ssm_test">
39 
40             <property name="enableSubPackages" value="false" />
41             <property name="trimStrings" value="true" />
42         </javaModelGenerator>
43         <!--生成SQLMAP.xml文件 -->
44         <sqlMapGenerator targetPackage="user_information.persistence"  targetProject="ssm_test">
45 
46             <property name="enableSubPackages" value="false" />
47         </sqlMapGenerator>
48         <!--生成Dao文件 可以配置 type="XMLMAPPER"生成xml的dao实现  context id="DB2Tables" 修改targetRuntime="MyBatis3"  -->
49         <javaClientGenerator type="XMLMAPPER" targetPackage="user_information.persistence"  targetProject="ssm_test">
50 
51             <property name="enableSubPackages" value="false" />
52         </javaClientGenerator>
53  
54         <!--对应数据库表 mysql可以加入主键自增 字段命名 忽略某字段等-->
55         <table tableName="user_information" domainObjectName="User_information" enableCountByExample="false" enableSelectByExample="true" enableUpdateByExample="false" enableDeleteByExample="false" selectByExampleQueryId="false">
56 
57         </table>
58  
59          
60     </context>
61 </generatorConfiguration>
generatorConfig.xml

 

这是我的项目,刚创建什么都木有

下面是sql

 

求助哪里的问题???

cocoyoona的主页 cocoyoona | 初学一级 | 园豆:20
提问于:2016-05-30 15:52
< >
分享
最佳答案
1

mybatis配置文件里面配置问题,运行就出错,找一个例子比较一下就行了

收获园豆:10
小光 | 小虾三级 |园豆:1766 | 2016-05-30 15:58

 (⊙o⊙)我好想web.xml还没配置...

cocoyoona | 园豆:20 (初学一级) | 2016-05-30 16:00

@眉间剪水泛千愁: 。。。还是虎,这种点击运行报错最简单,找个例子比较一下就行了,就是写配置错了,和逻辑没关系

小光 | 园豆:1766 (小虾三级) | 2016-05-30 16:03

@小光: 我copy的嘛

cocoyoona | 园豆:20 (初学一级) | 2016-05-30 16:06

@眉间剪水泛千愁: 那看一下数据库驱动jar包,driverClass,数据库名,用户名,密码对不对

小光 | 园豆:1766 (小虾三级) | 2016-05-30 16:09

@小光: 茫然...

cocoyoona | 园豆:20 (初学一级) | 2016-05-30 16:11

@眉间剪水泛千愁: 茫然什么。。。复制过来配置文件把里面的参数换成你的

小光 | 园豆:1766 (小虾三级) | 2016-05-30 16:13
其他回答(2)
0

要学会自己建、不要老依托工具自动生成。后续问题才是噩梦来袭~

Ctrl` | 园豆:3317 (老鸟四级) | 2016-05-30 15:54

 皓皓.我现在在学你不要打击我

支持(0) 反对(0) cocoyoona | 园豆:20 (初学一级) | 2016-05-30 15:56

@眉间剪水泛千愁: 哦(⊙_⊙)、我也忘了。一年多没用过了。代码还知道点。框架这种的配置忘得差不多了

支持(0) 反对(0) Ctrl` | 园豆:3317 (老鸟四级) | 2016-05-30 15:57

@g皓皓: 去帮我呼叫帮手呗

支持(0) 反对(0) cocoyoona | 园豆:20 (初学一级) | 2016-05-30 16:00

@眉间剪水泛千愁: 哦..

支持(0) 反对(0) Ctrl` | 园豆:3317 (老鸟四级) | 2016-05-30 16:13
0
<?xml version="1.0" encoding="UTF-8"?>
  <beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
  xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
  xsi:schemaLocation="
  http://www.springframework.org/schema/beans
  http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
  http://www.springframework.org/schema/tx
  http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
  http://www.springframework.org/schema/context
  http://www.springframework.org/schema/context/spring-context-3.2.xsd
  http://www.springframework.org/schema/aop
  http://www.springframework.org/schema/aop/spring-aop-3.2.xsd">
   
  <!-- myBatis文件 -->
  <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
  <property name="dataSource" ref="dataSource" />
  <!-- mybatis配置文件 -->
  <!-- 自动扫描entity目录, 省掉Configuration.xml里的手工配置 -->
  <property name="mapperLocations" value="classpath:com/**/mapping/*Mapper.xml" />
  </bean>
  <!-- DAO接口所在包名,Spring会自动查找其下的类 -->
  <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
  <property name="basePackage" value="com.**.dao" />
  <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
  </bean>
   
  <!-- 配置事务管理器 -->
  <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
  <property name="dataSource" ref="dataSource" />
  </bean>
  </beans>
<?xml version="1.0" encoding="UTF-8"?>
  <beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
  xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
  xsi:schemaLocation="
  http://www.springframework.org/schema/beans
  http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
  http://www.springframework.org/schema/tx
  http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
  http://www.springframework.org/schema/context
  http://www.springframework.org/schema/context/spring-context-3.2.xsd
  http://www.springframework.org/schema/aop
  http://www.springframework.org/schema/aop/spring-aop-3.2.xsd">
   
  <!-- 数据源 C3P0的配置-->
  <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
  <!-- 用户名-->
  <property name="user" value="${username}"/>
  <!-- 用户密码-->
  <property name="password" value="${password}"/>
  <property name="driverClass" value="${driver}"/>
  <property name="jdbcUrl" value="${url}"/>
   
  <!--连接池中保留的最大连接数。默认值: 15 -->
  <property name="maxPoolSize" value="20"/>
  <!-- 连接池中保留的最小连接数,默认为:3-->
  <property name="minPoolSize" value="2"/>
  <!-- 初始化连接池中的连接数,取值应在minPoolSize与maxPoolSize之间,默认为3-->
  <property name="initialPoolSize" value="2"/>
   
  <!--最大空闲时间,60秒内未使用则连接被丢弃。若为0则永不丢弃。默认值: 0 -->
  <property name="maxIdleTime" value="60"/>
   
  <!-- 当连接池连接耗尽时,客户端调用getConnection()后等待获取新连接的时间,超时后将抛出SQLException,如设为0则无限期等待。单位毫秒。默认: 0 -->
  <property name="checkoutTimeout" value="3000"/>
   
  <!--当连接池中的连接耗尽的时候c3p0一次同时获取的连接数。默认值: 3 -->
  <property name="acquireIncrement" value="2"/>
   
  <!--定义在从数据库获取新连接失败后重复尝试的次数。默认值: 30 ;小于等于0表示无限次-->
  <property name="acquireRetryAttempts" value="0"/>
   
  <!--重新尝试的时间间隔,默认为:1000毫秒-->
  <property name="acquireRetryDelay" value="1000"/>
   
  <!--关闭连接时,是否提交未提交的事务,默认为false,即关闭连接,回滚未提交的事务 -->
  <property name="autoCommitOnClose" value="false"/>
   
  <!--c3p0将建一张名为Test的空表,并使用其自带的查询语句进行测试。如果定义了这个参数那么属性preferredTestQuery将被忽略。你不能在这张Test表上进行任何操作,它将只供c3p0测试使用。默认值: null -->
  <property name="automaticTestTable" value="Test"/>
   
  <!--如果为false,则获取连接失败将会引起所有等待连接池来获取连接的线程抛出异常,但是数据源仍有效保留,并在下次调用getConnection()的时候继续尝试获取连接。如果设为true,那么在尝试获取连接失败后该数据源将申明已断开并永久关闭。默认: false-->
  <property name="breakAfterAcquireFailure" value="false"/>
   
  <!--每60秒检查所有连接池中的空闲连接。默认值: 0,不检查 -->
  <property name="idleConnectionTestPeriod" value="60"/>
  <!--c3p0全局的PreparedStatements缓存的大小。如果maxStatements与maxStatementsPerConnection均为0,则缓存不生效,只要有一个不为0,则语句的缓存就能生效。如果默认值: 0-->
  <property name="maxStatements" value="100"/>
  <!--maxStatementsPerConnection定义了连接池内单个连接所拥有的最大缓存statements数。默认值: 0 -->
  <property name="maxStatementsPerConnection" value="1"/>
  </bean>
  </beans>
[3] | 园豆:1174 (小虾三级) | 2016-05-30 16:00

 这是神马啊宝宝?

支持(0) 反对(0) cocoyoona | 园豆:20 (初学一级) | 2016-05-30 16:06

@眉间剪水泛千愁: spring+mybaits整合呀,直接注解开发,配置好了告别xml。。。你给不给我豆豆

支持(0) 反对(0) [3] | 园豆:1174 (小虾三级) | 2016-05-30 16:08

@殴打小学生: 你要豆豆,可以,但是我这个问题怎么解决呀

支持(0) 反对(0) cocoyoona | 园豆:20 (初学一级) | 2016-05-30 16:11

@眉间剪水泛千愁: 。。。

支持(0) 反对(0) [3] | 园豆:1174 (小虾三级) | 2016-05-30 16:12
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册