Laughing girl2021
2022-05-18 22:27
采纳率: 100%
浏览 24

学习ssm反向工程时遇到问题,运行下面代码后不能连接数据库?JDBC异常?请问是什么原因?

jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/51zxw?characterEncoding=utf-8
jdbc.username=root
jdbc.password=123456



<!DOCTYPE generatorConfiguration
        PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
        "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">

<generatorConfiguration>
    <!--引入外部的数据配置属性信息-->
    <properties resource="db.properties"/>

    <context id="Mysql" targetRuntime="MyBatis3Simple" defaultModelType="flat">
        <property name="beginningDelimiter" value="`"/>
        <property name="endingDelimiter" value="`"/>

        <plugin type="tk.mybatis.mapper.generator.MapperPlugin">
            <property name="mappers" value="tk.mybatis.mapper.common.Mapper"/>
            <property name="caseSensitive" value="true"/>
        </plugin>

        <jdbcConnection driverClass="${jdbc.driver}"
                        connectionURL="${jdbc.url}"
                        userId="${jdbc.username}"
                        password="${jdbc.password}">
        </jdbcConnection>
        <!--实体类位置-->
        <javaModelGenerator targetPackage="com.wyzxw.entity"
                            targetProject="src/main/java"/>
        <!--XXXMapper.xml-->
        <sqlMapGenerator targetPackage="mapper"
                         targetProject="src/main/resources"/>
        <!--XXXMapper接口-->
        <javaClientGenerator targetPackage="com.wyzxw.mapper"
                             targetProject="src/main/java"
                             type="XMLMAPPER"/>

        <table tableName="Employee" domainObjectName="Employee">
            <!--column是指定表中主键的名字,所以在建表时要有主键-->
            <generatedKey column="empid" sqlStatement="JDBC"/>
        </table>
        <table tableName="Depart" domainObjectName="Depart">
            <generatedKey column="depid" sqlStatement="JDBC"/>
        </table>
    </context>
</generatorConfiguration>

1条回答 默认 最新

相关推荐 更多相似问题