ssm配置
1、Dynamic Web Module 3.1,配置web.xml文件头信息
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1"> <display-name>Archetype Created Web Application</display-name> </web-app>
2、指定JDK1.8编译环境,配置pom.xml
<build> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> </build>
3、添加mybatis-generator插件,配置pom.xml
<build> <plugins> <plugin> <groupId>org.mybatis.generator</groupId> <artifactId>mybatis-generator-maven-plugin</artifactId> <version>1.3.7</version> <goals> <glal>generator</glal> </goals> <configuration> <verbose>true</verbose> <overwrite>true</overwrite> </configuration> </plugin> </plugins> </build>
maven命令
mybatis-generator:generate
4、resources目录,添加generatorConfig.xml配置文件
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd"> <generatorConfiguration> <classPathEntry location="D:\ojdbc_mysql5.1.18.jar" /> <!-- <classPathEntry location="D:\ojdbc6.jar" /> --> <context id="tables" targetRuntime="MyBatis3"> <!-- 注释tww --> <commentGenerator> <!-- 是否取消注释 --> <property name="suppressAllComments" value="true" /> </commentGenerator> <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://127.0.0.1:3306/hr_mysql" userId="root" password="root"> </jdbcConnection> <!-- <jdbcConnection --> <!-- driverClass="oracle.jdbc.driver.OracleDriver" --> <!-- connectionURL="jdbc:oracle:thin:@192.168.1.201:1521/orcl" --> <!-- userId="hr_oracle" password="123456"> --> <!-- </jdbcConnection> --> <javaTypeResolver> <property name="forceBigDecimals" value="false" /> </javaTypeResolver> <!--自动生成的实体的存放包路径 --> <javaModelGenerator targetPackage="com.huiruan.base.entity" targetProject="src/main/java"> <property name="enableSubPackages" value="true" /> <property name="trimStrings" value="true" /> </javaModelGenerator> <!--自动生成的*Mapper.xml文件存放路径 --> <sqlMapGenerator targetPackage="com.huiruan.base.mapper" targetProject="src/main/java"> <property name="enableSubPackages" value="true" /> </sqlMapGenerator> <!--自动生成的*Mapper.java存放路径 --> <javaClientGenerator type="XMLMAPPER" targetPackage="com.huiruan.base.dao" targetProject="src/main/java"> <property name="enableSubPackages" value="true" /> </javaClientGenerator> <table tableName="sys_user" domainObjectName="SysUser" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" /> </context> </generatorConfiguration>