开发常用模板

web.xml <web-app> 3.1模板
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
         http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
spring MVC dispatcher-servlet.xml 模板
<?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:tx="http://www.springframework.org/schema/cache"
       xsi:schemaLocation="
					 http://www.springframework.org/schema/beans
					 http://www.springframework.org/schema/beans/spring-beans.xsd
					 http://www.springframework.org/schema/tx
					 http://www.springframework.org/schema/tx/spring-tx.xsd
					 http://www.springframework.org/schema/cache
					 http://www.springframework.org/schema/aop
					 http://www.springframework.org/schema/aop/spring-aop.xsd">
mapper.xml头文件模板
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="">

</mapper>
spring-servlet.xml
<?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:mvc="http://www.springframework.org/schema/mvc"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
			           http://www.springframework.org/schema/beans/spring-beans.xsd
			           http://www.springframework.org/schema/mvc
			           http://www.springframework.org/schema/mvc/spring-mvc.xsd
			           http://www.springframework.org/schema/context
			           http://www.springframework.org/schema/context/spring-context.xsd">
普通jsp头部
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
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>
	<!--指定特定数据库的jdbc驱动jar包的位置-->
	<classPathEntry location="E:\reposi\mysql\mysql-connector-java\5.1.38\mysql-connector-java-5.1.38.jar"/>
       <context id="DB2Tables" targetRuntime="MyBatis3">
     	<!--去除注释-->
	    <commentGenerator>
     		<property name="suppressDate" value="true"/>
        	<property name="suppressAllComments" value="true"/>
        </commentGenerator>
        
        <!--连接数据库-->
        <jdbcConnection driverClass="com.mysql.jdbc.Driver"
                       	connectionURL="jdbc:mysql://localhost:3306/appinfodb"
                        userId="root"
                        password="111111">
        </jdbcConnection>

        <!-- 非必需,类型处理器,在数据库类型和java类型之间的转换控制-->
        <javaTypeResolver>
        	<property name="forceBigDecimals" value="false"/>
        </javaTypeResolver>
		
		<!-- Model模型生成器,用来生成pojo类 targetPackage 指定生成pojo的包名 targetProject 指定该包在项目下的路径 -->
        <javaModelGenerator targetPackage="com.zgx.pojo" targetProject="src\main\java">
        	<!-- 是否允许子包 -->
        	<property name="enableSubPackages" value="true"/>
        	<!-- 是否对类CHAR类型的列的数据进行trim操作 -->
        	<property name="trimStrings" value="true"/>
        </javaModelGenerator>
		
		<!--Mapper映射文件生成所在的目录 为每一个数据库的表生成对应的SqlMap文件,尽量不用它生成的mapper -->
        <sqlMapGenerator targetPackage="com.zgx.mapper" targetProject="src\main\resources">
        	<property name="enableSubPackages" value="true"/>
        </sqlMapGenerator>

		<!--Mapper接口文件生成所在的目录 生成控制数据库的mybatis的接口类,尽量不用它生成的接口 -->
        <javaClientGenerator type="XMLMAPPER" targetPackage="com.zgx.mapper" targetProject="src\main\java">
            <property name="enableSubPackages" value="true"/>
        </javaClientGenerator>
		
		<!-- 指定要进行逆向的数据表名,tableName如果设为"%",则表示查询数据库所有表,一般生成完记得在tableName设置标记避免再次生成 -->
        <table schema="DB2ADMIN" tableName="dev_user" domainObjectName="DevUser" enableCountByExample="false"
               enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false"
               selectByExampleQueryId="false">
               <property name="useActualColumnNames" value="true"/>
        </table>
	</context>
</generatorConfiguration>

猜你喜欢

转载自blog.csdn.net/weixin_40743261/article/details/86635071