idea中ssm自动配置

自动生成

只需要创建好maven项目,然后创建一个类Test,复制代码粘贴即可

使用注意:

代码

import java.io.*;

public class Test {
    //包名格式
    //列如配置到com.wbg.ssm包下  程序会自动添加dao\controller\service\entity
    private final static String com = "com.wbg.ssm";
    //数据库名称
    private final static String database = "";
    //数据库账号
    private final static String user = "root";
    //数据库密码
    private final static String password = "123456";

    public static void main(String[] args) throws IOException {

        createStart();

    }

    static void createStart() {
        //获取当前项目的路径
        String url = System.getProperty("user.dir");
        System.out.println("开始配置pom.xml");
        System.out.println(configPomXml(url));
        url = url + File.separator + "src" + File.separator + "main";
        System.out.println("开始配置resources目录");
        createResources(url + File.separator + "resources");
        System.out.println("完成配置resources目录");
        System.out.println("开始配置webapp目录");
        createWebapp(url + File.separator + "webapp");
        System.out.println("完成配置webapp目录");

    }

    //***********************Resources************************

    /**
     * 创建四个配置文件
     * dbc.properties
     * log4j.properties
     * mybatis-config.xml
     * spring-web.xml
     *
     * @return
     */
    static boolean createResources(String url) {
        if (createJdbcProperties(url)) {
            System.out.println("jdbc.properties配置成功");
        } else {
            System.out.println("jdbc.properties配置失败");
        }
        if (log4jProperties(url)) {
            System.out.println("log4j.properties配置成功");
        } else {
            System.out.println("log4j.properties配置失败");
        }
        if (mybatisConfig(url)) {
            System.out.println("mybatis-config.xml配置成功");
        } else {
            System.out.println("mybatis-config.xml配置失败");
        }
        if (springWeb(url)) {
            System.out.println("spring-web.xml配置成功");
        } else {
            System.out.println("spring-web.xml配置失败");
        }
        if (generatorConfig(url)) {
            System.out.println("generatorConfig.xml配置成功");
        } else {
            System.out.println("generatorConfig.xml配置失败");
        }

        //\resources\spring
        if (springDao(url + File.separator + "spring")) {
            System.out.println("spring-dao.xml配置成功");
        } else {
            System.out.println("spring-dao.xml配置失败");
        }
        //\resources\spring
        if (springService(url + File.separator + "spring")) {
            System.out.println("spring-service.xml配置成功");
        } else {
            System.out.println("spring-service.xml配置失败");
        }

        return true;
    }

    /**
     * 创建jdbc.properties配置文件
     *
     * @param url 路径
     * @return
     */
    static boolean createJdbcProperties(String url) {
        File file = new File(url, "jdbc.properties");
        String context = "jdbc.driver=org.mariadb.jdbc.Driver\n" +
                "jdbc.url=jdbc:mariadb://localhost:3306/" + database + "\n" +
                "jdbc.user="+user+"\n" +
                "jdbc.password="+password+"";
        return createFile(file, context);
    }

    /**
     * 创建log4j.properties日志文件
     *
     * @param url 路径
     * @return
     */
    static boolean log4jProperties(String url) {
        File file = new File(url, "log4j.properties");

        String context = "# Global logging configuration\n" +
                "log4j.rootLogger=ERROR, ooo\n" +
                "\n" +
                "# MyBatis logging configuration...\n" +
                "log4j.logger." + com + ".dao=DEBUG\n" +
                "\n" +
                "# 规则1,名字为 ooo,向标准输出 System.err/out\n" +
                "log4j.appender.ooo=org.apache.log4j.ConsoleAppender\n" +
                "log4j.appender.ooo.layout=org.apache.log4j.PatternLayout\n" +
                "log4j.appender.ooo.layout.ConversionPattern=%5p [%t] ~ %m%n\n";
        return createFile(file, context);
    }

    /**
     * 创建mybatis-config.xml配置文件
     *
     * @param url 路径
     * @return
     */
    static boolean mybatisConfig(String url) {
        File file = new File(url, "mybatis-config.xml");

        String context = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" +
                "<!DOCTYPE configuration PUBLIC \"-//mybatis.org//DTD Config 3.0//EN\" \"http://mybatis.org/dtd/mybatis-3-config.dtd\">\n" +
                "\n" +
                "\n" +
                "<configuration>\n" +
                "    <settings>\n" +
                "        <!-- 使用jdbc的getGeneratedKeys获取数据库自增主键值 -->\n" +
                "        <setting name=\"useGeneratedKeys\" value=\"true\" />\n" +
                "        <!-- 使用列别名替换列名 默认:true -->\n" +
                "        <setting name=\"useColumnLabel\" value=\"true\" />\n" +
                "        <!-- 开启驼峰命名转换:Table {create_time} -> Entity {createTime} -->\n" +
                "        <setting name=\"mapUnderscoreToCamelCase\" value=\"true\" />\n" +
                "    </settings>\n" +
                "\n" +
                "    <plugins>\n" +
                "        <plugin interceptor=\"com.github.pagehelper.PageInterceptor\" />\n" +
                "    </plugins>\n" +
                "</configuration>";
        return createFile(file, context);
    }

    /**
     * 创建spring-web.xml配置文件
     *
     * @return
     */
    static boolean springWeb(String url) {
        File file = new File(url, "spring-web.xml");

        String context = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                "<beans xmlns=\"http://www.springframework.org/schema/beans\"\n" +
                "       xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" +
                "       xmlns:context=\"http://www.springframework.org/schema/context\"\n" +
                "       xmlns:mvc=\"http://www.springframework.org/schema/mvc\"\n" +
                "       xsi:schemaLocation=\"http://www.springframework.org/schema/beans\n" +
                "\thttp://www.springframework.org/schema/beans/spring-beans.xsd\n" +
                "\thttp://www.springframework.org/schema/context\n" +
                "\thttp://www.springframework.org/schema/context/spring-context.xsd\n" +
                "\thttp://www.springframework.org/schema/mvc\n" +
                "\thttp://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd\">\n" +
                "    <!-- 配置SpringMVC -->\n" +
                "    <!-- 1.开启SpringMVC注解模式 -->\n" +
                "    <!-- 简化配置:\n" +
                "        (1)自动注册DefaultAnootationHandlerMapping,AnotationMethodHandlerAdapter\n" +
                "        (2)提供一些列:数据绑定,数字和日期的format @NumberFormat, @DateTimeFormat, xml,json默认读写支持\n" +
                "    -->\n" +
                "    <mvc:annotation-driven />\n" +
                "\n" +
                "    <!-- 2.静态资源默认servlet配置\n" +
                "        (1)加入对静态资源的处理:js,gif,png\n" +
                "        (2)允许使用\"/\"做整体映射\n" +
                "     -->\n" +
                "    <mvc:default-servlet-handler/>\n" +
                "\n" +
                "    <!-- 3.配置jsp 显示ViewResolver -->\n" +
                "  <bean class=\"org.springframework.web.servlet.view.InternalResourceViewResolver\">\n" +
                "        <property name=\"viewClass\" value=\"org.springframework.web.servlet.view.JstlView\" />\n" +
                "        <property name=\"prefix\" value=\"/WEB-INF/jsp/\" />\n" +
                "        <property name=\"suffix\" value=\".jsp\" />\n" +
                "    </bean>\n" +
                "    <!-- 4.扫描web相关的bean -->\n" +
                "    <context:component-scan base-package=\"" + com + ".controller\" />\n" +
                "</beans>";
        return createFile(file, context);
    }

    /**
     * 创建spring-dao.xml配置文件
     *
     * @param url 路径
     * @return
     */
    static boolean springDao(String url) {
        File file = new File(url, "spring-dao.xml");
        String context = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                "<beans xmlns=\"http://www.springframework.org/schema/beans\"\n" +
                "       xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" +
                "       xmlns:tx=\"http://www.springframework.org/schema/tx\" xmlns:context=\"http://www.springframework.org/schema/context\"\n" +
                "       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/context http://www.springframework.org/schema/context/spring-context.xsd\">\n" +
                "\n" +
                "\n" +
                "\n" +
                "    <!-- 配置整合mybatis过程 -->\n" +
                "    <!-- 1.配置数据库相关参数properties的属性:${url} -->\n" +
                "    <context:property-placeholder location=\"classpath:jdbc.properties\" />\n" +
                "\n" +
                "    <!-- 2.数据库连接池 -->\n" +
                "    <bean id=\"dataSource\" class=\"com.mchange.v2.c3p0.ComboPooledDataSource\">\n" +
                "        <property name=\"driverClass\" value=\"${jdbc.driver}\" />\n" +
                "        <property name=\"jdbcUrl\" value=\"${jdbc.url}\" />\n" +
                "        <property name=\"user\" value=\"${jdbc.username}\" />\n" +
                "        <property name=\"password\" value=\"${jdbc.password}\" />\n" +
                "\n" +
                "        <!-- c3p0连接池的私有属性 -->\n" +
                "        <property name=\"maxPoolSize\" value=\"30\" />\n" +
                "        <property name=\"minPoolSize\" value=\"10\" />\n" +
                "        <!-- 关闭连接后不自动commit -->\n" +
                "        <property name=\"autoCommitOnClose\" value=\"false\" />\n" +
                "        <!-- 获取连接超时时间 -->\n" +
                "        <property name=\"checkoutTimeout\" value=\"10000\" />\n" +
                "        <!-- 当获取连接失败重试次数 -->\n" +
                "        <property name=\"acquireRetryAttempts\" value=\"2\" />\n" +
                "    </bean>\n" +
                "\n" +
                "    <!-- 3.配置SqlSessionFactory对象 -->\n" +
                "    <bean id=\"sqlSessionFactory\" class=\"org.mybatis.spring.SqlSessionFactoryBean\">\n" +
                "        <!-- 注入数据库连接池 -->\n" +
                "        <property name=\"dataSource\" ref=\"dataSource\" />\n" +
                "        <!-- 配置MyBaties全局配置文件:mybatis-config.xml -->\n" +
                "        <property name=\"configLocation\" value=\"classpath:mybatis-config.xml\" />\n" +
                "        <!-- 扫描entity包 使用别名 -->\n" +
                "        <property name=\"typeAliasesPackage\" value=\"" + com + ".entity\" />\n" +
                "        <!-- 扫描sql配置文件:mapper需要的xml文件 -->\n" +
                "        <property name=\"mapperLocations\" value=\"classpath:mapper/*.xml\" />\n" +
                "    </bean>\n" +
                "\n" +
                "    <!-- 4.配置扫描Dao接口包,动态实现Dao接口,注入到spring容器中 -->\n" +
                "    <bean class=\"org.mybatis.spring.mapper.MapperScannerConfigurer\">\n" +
                "        <!-- 注入sqlSessionFactory -->\n" +
                "        <property name=\"sqlSessionFactoryBeanName\" value=\"sqlSessionFactory\" />\n" +
                "        <!-- 给出需要扫描Dao接口包 -->\n" +
                "        <property name=\"basePackage\" value=\"" + com + ".dao\" />\n" +
                "    </bean>\n" +
                "\n" +
                "    <!--配置声明式事务管理-->\n" +
                "    <bean id=\"transactionManager\" class=\"org.springframework.jdbc.datasource.DataSourceTransactionManager\">\n" +
                "        <property name=\"dataSource\" ref=\"dataSource\" />\n" +
                "    </bean>\n" +
                "    <tx:annotation-driven proxy-target-class=\"true\" />\n" +
                "\n" +
                "</beans>";
        return createFile(file, context);
    }

    /**
     * 创建spring-service.xml配置文件
     *
     * @param url 路径
     * @return
     */
    static boolean springService(String url) {
        File file = new File(url, "spring-service.xml");
        String context = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                "<beans xmlns=\"http://www.springframework.org/schema/beans\"\n" +
                "       xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" +
                "       xmlns:context=\"http://www.springframework.org/schema/context\"\n" +
                "       xmlns:tx=\"http://www.springframework.org/schema/tx\" xmlns:mvc=\"http://www.springframework.org/schema/mvc\"\n" +
                "       xmlns:aop=\"http://www.springframework.org/schema/aop\"\n" +
                "       xsi:schemaLocation=\"http://www.springframework.org/schema/beans\n" +
                "\thttp://www.springframework.org/schema/beans/spring-beans.xsd\n" +
                "\thttp://www.springframework.org/schema/context\n" +
                "\thttp://www.springframework.org/schema/context/spring-context.xsd\n" +
                " http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd\">\n" +
                "    <!-- 扫描service包下所有使用注解的类型 -->\n" +
                "    <context:component-scan base-package=\"" + com + ".service\" />\n" +
                "    <mvc:annotation-driven />\n" +
                "    <!-- 启用 aspectj 方式 AOP-->\n" +
                "    <aop:aspectj-autoproxy proxy-target-class=\"true\" />\n" +
                "</beans>";
        return createFile(file, context);
    }

    /**
     * 创建generatorConfig.xml配置文件
     * @param url
     * @return
     */
    static boolean generatorConfig(String url) {
        File file = new File(url, "generatorConfig.xml");
        String context = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                "<!DOCTYPE generatorConfiguration\n" +
                "        PUBLIC \"-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN\"\n" +
                "        \"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd\">\n" +
                "\n" +
                "<generatorConfiguration>\n" +
                "\n" +
                "    <context id=\"xxx\" targetRuntime=\"MyBatis3Simple\">\n" +
                "\n" +
                "\n" +
                "        <commentGenerator>\n" +
                "            <property name=\"suppressDate\" value=\"true\" />\n" +
                "        </commentGenerator>\n" +
                "        <!-- 数据库连接 -->\n" +
                "        <jdbcConnection driverClass=\"org.mariadb.jdbc.Driver\"\n" +
                "                        connectionURL=\"jdbc:mariadb://localhost/"+database+"\"\n" +
                "                        userId=\""+user+"\" password=\""+password+"\">\n" +
                "        </jdbcConnection>\n" +
                "\n" +
                "        <!-- Model生成规则 -->\n" +
                "        <javaModelGenerator targetPackage=\""+com+".entity\" targetProject=\"src/main/java\">\n" +
                "            <property name=\"trimStrings\" value=\"true\" />\n" +
                "        </javaModelGenerator>\n" +
                "\n" +
                "        <sqlMapGenerator targetPackage=\"mapper\"  targetProject=\"src/main/resources\"/>\n" +
                "        <!-- dao 规则 -->\n" +
                "        <javaClientGenerator type=\"XMLMAPPER\" targetPackage=\""+com+".dao\"  targetProject=\"src/main/java\">\n" +
                "            <property name=\"enableSubPackages\" value=\"true\" />\n" +
                "        </javaClientGenerator>\n" +
                "        <table tableName=\"%\">\n" +
                "            <generatedKey column=\"id\" sqlStatement=\"Mysql\"/>\n" +
                "        </table>\n" +
                "    </context>\n" +
                "</generatorConfiguration>";
        return createFile(file, context);
    }


    //***********************webapp************************
    static boolean createWebapp(String url) {
        if (webXml(url + File.separator + "WEB-INF")) {
            System.out.println("web.xml配置成功");
        } else {
            System.out.println("web.xml配置失败");
        }
        createCSSJSDirectory(url + File.separator);
        return true;
    }

    /**
     * 创建WEB-INF\web.xml配置文件
     *
     * @param url 路径
     * @return
     */
    static boolean webXml(String url) {
        File file = new File(url, "web.xml");
        String context = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                "<web-app xmlns=\"http://xmlns.jcp.org/xml/ns/javaee\"\n" +
                "         xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" +
                "         xsi:schemaLocation=\"http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd\"\n" +
                "         version=\"4.0\">\n" +
                "\n" +
                "    <display-name>自动生成</display-name>\n" +
                "\n" +
                "    <!--解决中文乱码-->\n" +
                "    <filter>\n" +
                "        <filter-name>encodingFilter</filter-name>\n" +
                "        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>\n" +
                "        <async-supported>true</async-supported>\n" +
                "        <init-param>\n" +
                "            <param-name>encoding</param-name>\n" +
                "            <param-value>UTF-8</param-value>\n" +
                "        </init-param>\n" +
                "\n" +
                "    </filter>\n" +
                "    <filter-mapping>\n" +
                "        <filter-name>encodingFilter</filter-name>\n" +
                "        <url-pattern>/*</url-pattern>\n" +
                "    </filter-mapping>\n" +
                "\n" +
                "    <!--配置 Spring 的容器-->\n" +
                "    <context-param>\n" +
                "        <param-name>contextConfigLocation</param-name>\n" +
                "        <param-value>classpath:spring/spring-*.xml</param-value>\n" +
                "    </context-param>\n" +
                "    <listener>\n" +
                "        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>\n" +
                "    </listener>\n" +
                "\n" +
                "    <!--配置 MVC 容器-->\n" +
                "    <!--将所有的请求都交给 Spring MVC 处理-->\n" +
                "    <servlet>\n" +
                "        <servlet-name>app</servlet-name>\n" +
                "        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>\n" +
                "        <init-param>\n" +
                "            <param-name>contextConfigLocation</param-name>\n" +
                "            <param-value>classpath:spring-web.xml</param-value>\n" +
                "        </init-param>\n" +
                "    </servlet>\n" +
                "    <servlet-mapping>\n" +
                "        <servlet-name>app</servlet-name>\n" +
                "        <url-pattern>/</url-pattern>\n" +
                "    </servlet-mapping>\n" +
                "</web-app>";
        return createFile(file, context);
    }

    /**
     * 创建css和js
     *
     * @param url 路径
     */
    static boolean createCSSJSDirectory(String url) {
        File fcss = new File(url + "css");
        if (fcss.mkdirs()) {
            System.out.println("成功创建css文件夹");
        }
        File fjs = new File(url + "js");
        if (fjs.mkdirs()) {
            System.out.println("成功创建js文件夹");
        }

        return true;
    }

    /**
     * @param file    创建的文件
     * @param context 文件里面的内容
     */
    static boolean createFile(File file, String context) {
        //获取文件
        File parent = file.getParentFile();
        //如果是目录
        if (parent != null) {
            //创建目录
            parent.mkdirs();
        }
        try {
            //创建文件
            file.createNewFile();
            FileWriter fileWriter = null;
            try {
                fileWriter = new FileWriter(file);
                fileWriter.write(context);
                fileWriter.flush();
                fileWriter.close();
            } catch (IOException e) {
                return false;
            }
        } catch (IOException e) {
            System.out.println("创建文件失败:" + e.getMessage());
        }
        return true;
    }


    //***********************pom.xml************************

    /**
     * 配置pom.xml文件
     *
     * @param url 路径
     */
    static String configPomXml(String url) {
        File file = new File(url, "pom.xml");
        InputStream inputStream = null;
        byte b[] = new byte[Integer.parseInt(String.valueOf(file.length()))];
        StringBuffer stringBuffer = null;
        try {
            inputStream = new FileInputStream(file);
            inputStream.read(b);
            inputStream.close();
            stringBuffer = new StringBuffer(new String(b));
            stringBuffer.replace(Integer.parseInt(String.valueOf(file.length())) - 10, Integer.parseInt(String.valueOf(file.length())), "");
            stringBuffer.append(pomContext());
        } catch (Exception e) {
            return "程序出错,请重试 -- pom.xml文件配置失败";
        }
        if (createFile(file, stringBuffer.toString())) {
            return "pom.xml文件配置完成";
        }
        return "pom.xml文件配置失败";
    }

    /**
     * pom.xml配置文件需要加的配置
     *
     * @return
     */
    static String pomContext() {
        return "<!--打包-->\n" +
                "    <packaging>war</packaging>\n" +
                "    <!--设置编码-->\n" +
                "    <properties>\n" +
                "        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>\n" +
                "        <maven.compiler.source>1.8</maven.compiler.source>\n" +
                "        <maven.compiler.target>1.8</maven.compiler.target>\n" +
                "        <spring.version>5.1.0.RELEASE</spring.version>\n" +
                "    </properties>\n" +
                "    <!--引入文件-->\n" +
                "    <dependencies>\n" +
                "        <!-- Spring Web MVC -->\n" +
                "        <dependency>\n" +
                "            <groupId>org.springframework</groupId>\n" +
                "            <artifactId>spring-web</artifactId>\n" +
                "            <version>${spring.version}</version>\n" +
                "        </dependency>\n" +
                "        <dependency>\n" +
                "            <groupId>org.springframework</groupId>\n" +
                "            <artifactId>spring-webmvc</artifactId>\n" +
                "            <version>${spring.version}</version>\n" +
                "        </dependency>\n" +
                "\n" +
                "        <!-- servlet 系列的支持 -->\n" +
                "        <dependency>\n" +
                "            <groupId>javax</groupId>\n" +
                "            <artifactId>javaee-api</artifactId>\n" +
                "            <version>8.0</version>\n" +
                "            <scope>provided</scope>\n" +
                "        </dependency>\n" +
                "        <dependency>\n" +
                "            <groupId>javax.servlet</groupId>\n" +
                "            <artifactId>jstl</artifactId>\n" +
                "            <version>1.2</version>\n" +
                "        </dependency>\n" +
                "\n" +
                "        <dependency>\n" +
                "            <groupId>com.github.pagehelper</groupId>\n" +
                "            <artifactId>pagehelper</artifactId>\n" +
                "            <version>5.1.7</version>\n" +
                "        </dependency>\n" +
                "\n" +
                "        <!-- Springframework -->\n" +
                "        <dependency>\n" +
                "            <groupId>org.springframework</groupId>\n" +
                "            <artifactId>spring-context</artifactId>\n" +
                "            <version>${spring.version}</version>\n" +
                "        </dependency>\n" +
                "        <dependency>\n" +
                "            <groupId>org.springframework</groupId>\n" +
                "            <artifactId>spring-jdbc</artifactId>\n" +
                "            <version>${spring.version}</version>\n" +
                "        </dependency>\n" +
                "        <dependency>\n" +
                "            <groupId>org.springframework</groupId>\n" +
                "            <artifactId>spring-aop</artifactId>\n" +
                "            <version>${spring.version}</version>\n" +
                "        </dependency>\n" +
                "        <dependency>\n" +
                "            <groupId>org.aspectj</groupId>\n" +
                "            <artifactId>aspectjweaver</artifactId>\n" +
                "            <version>1.9.1</version>\n" +
                "        </dependency>\n" +
                "\n" +
                "        <!-- MyBatis -->\n" +
                "        <dependency>\n" +
                "            <groupId>org.mybatis</groupId>\n" +
                "            <artifactId>mybatis</artifactId>\n" +
                "            <version>3.4.6</version>\n" +
                "        </dependency>\n" +
                "        <dependency>\n" +
                "            <groupId>org.mybatis</groupId>\n" +
                "            <artifactId>mybatis-spring</artifactId>\n" +
                "            <version>1.3.2</version>\n" +
                "        </dependency>\n" +
                "\n" +
                "        <!-- 数据库驱动以及数据库连接池-->\n" +
                "        <dependency>\n" +
                "            <groupId>org.mariadb.jdbc</groupId>\n" +
                "            <artifactId>mariadb-java-client</artifactId>\n" +
                "            <version>2.3.0</version>\n" +
                "        </dependency>\n" +
                "        <dependency>\n" +
                "            <groupId>com.mchange</groupId>\n" +
                "            <artifactId>c3p0</artifactId>\n" +
                "            <version>0.9.5.2</version>\n" +
                "        </dependency>\n" +
                "\n" +
                "        <!-- 日志框架 -->\n" +
                "        <dependency>\n" +
                "            <groupId>log4j</groupId>\n" +
                "            <artifactId>log4j</artifactId>\n" +
                "            <version>1.2.17</version>\n" +
                "        </dependency>\n" +
                "\n" +
                "        <!-- 通用工具 -->\n" +
                "        <dependency>\n" +
                "            <groupId>com.fasterxml.jackson.core</groupId>\n" +
                "            <artifactId>jackson-databind</artifactId>\n" +
                "            <version>2.9.7</version>\n" +
                "        </dependency>\n" +
                "\n" +
                "        <!-- 单元测试 -->\n" +
                "        <dependency>\n" +
                "            <groupId>org.springframework</groupId>\n" +
                "            <artifactId>spring-test</artifactId>\n" +
                "            <version>${spring.version}</version>\n" +
                "            <scope>test</scope>\n" +
                "        </dependency>\n" +
                "\n" +
                "        <dependency>\n" +
                "            <groupId>junit</groupId>\n" +
                "            <artifactId>junit</artifactId>\n" +
                "            <version>4.12</version>\n" +
                "            <scope>test</scope>\n" +
                "        </dependency>\n" +
                "    </dependencies>\n" +
                "    <build>\n" +
                "        <finalName>contact</finalName>\n" +
                "        <plugins>\n" +
                "            <plugin>\n" +
                "                <groupId>org.mybatis.generator</groupId>\n" +
                "                <artifactId>mybatis-generator-maven-plugin</artifactId>\n" +
                "                <version>1.3.7</version>\n" +
                "                <dependencies>\n" +
                "                    <dependency>\n" +
                "                        <groupId>org.mariadb.jdbc</groupId>\n" +
                "                        <artifactId>mariadb-java-client</artifactId>\n" +
                "                        <version>2.3.0</version>\n" +
                "                    </dependency>\n" +
                "                </dependencies>\n" +
                "            </plugin>\n" +
                "        </plugins>\n" +
                "\n" +
                "        <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->\n" +
                "            <plugins>\n" +
                "                <plugin>\n" +
                "                    <artifactId>maven-clean-plugin</artifactId>\n" +
                "                    <version>3.0.0</version>\n" +
                "                </plugin>\n" +
                "                <!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging -->\n" +
                "                <plugin>\n" +
                "                    <artifactId>maven-resources-plugin</artifactId>\n" +
                "                    <version>3.0.2</version>\n" +
                "                </plugin>\n" +
                "                <plugin>\n" +
                "                    <artifactId>maven-compiler-plugin</artifactId>\n" +
                "                    <version>3.7.0</version>\n" +
                "                </plugin>\n" +
                "                <plugin>\n" +
                "                    <artifactId>maven-surefire-plugin</artifactId>\n" +
                "                    <version>2.20.1</version>\n" +
                "                </plugin>\n" +
                "                <plugin>\n" +
                "                    <artifactId>maven-war-plugin</artifactId>\n" +
                "                    <version>3.2.0</version>\n" +
                "                </plugin>\n" +
                "                <plugin>\n" +
                "                    <artifactId>maven-install-plugin</artifactId>\n" +
                "                    <version>2.5.2</version>\n" +
                "                </plugin>\n" +
                "                <plugin>\n" +
                "                    <artifactId>maven-deploy-plugin</artifactId>\n" +
                "                    <version>2.8.2</version>\n" +
                "                </plugin>\n" +
                "            </plugins>\n" +
                "        </pluginManagement>\n" +
                "    </build>\n\n" +
                "</project>";
    }

}
View Code

 运行后

 

posted @ 2018-11-30 14:42  韦邦杠  阅读(734)  评论(0编辑  收藏  举报