ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

Springboot+Mybits的配置文件

2022-04-16 18:31:06  阅读:40  来源: 互联网

标签:xml Springboot 配置文件 spring boot Mybits org log4j starter


application.xml

##### dev 配置 #######
spring:
  profiles:
    active: dev

  #数据库配置
  datasource:
    url: jdbc:mysql://localhost:3306/restaurant?serverTimezone=GMT%2B8&characterEncoding=utf-8&useSSL=false
    username: root
    password: zhangziyi1670
    driver-class-name: com.mysql.cj.jdbc.Driver
mybatis:
  mapper-locations: classpath*:com/example/mapper/*.xml
  config-location: classpath:mybaits-config.xml
View Code

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= "E:\MAVEN\maven-repo\mysql\mysql-connector-java\8.0.15\mysql-connector-java-8.0.15.jar" />

    <context id ="DB2Tables"  targetRuntime= "MyBatis3">

        <commentGenerator >

            <property name ="suppressDate" value="true"/>

            <!-- 是否去除自动生成的注释 true:是 : false:否 -->

            <property name ="suppressAllComments" value= "true"/>

        </commentGenerator >

        <!--数据库链接URL,用户名、密码 -->

        <jdbcConnection driverClass ="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/restaurant?serverTimezone=GMT%2B8" userId= "root" password ="zhangziyi1670">

        </jdbcConnection >

        <javaTypeResolver >

            <property name ="forceBigDecimals" value= "false"/>

        </javaTypeResolver >

        <!-- 生成模型的包名和位置-->

        <javaModelGenerator targetPackage="com.example.pojo" targetProject="src\main\java" >

            <property name ="enableSubPackages" value= "true"/>

            <property name ="trimStrings" value="true"/>

        </javaModelGenerator >

        <!-- 生成映射文件的包名和位置-->

        <sqlMapGenerator targetPackage="com.example.mapper" targetProject="src\main\resources" >

            <property name ="enableSubPackages" value= "true"/>

        </sqlMapGenerator >

        <!-- 生成DAO的包名和位置-->

        <javaClientGenerator type ="XMLMAPPER" targetPackage="com.example.dao" targetProject="src\main\java" >

            <property name ="enableSubPackages" value= "true"/>

        </javaClientGenerator >

        <!-- 要生成的表 tableName是数据库中的表名或视图名 domainObjectName是实体类名-->

        <table tableName ="sys_user" domainObjectName="userInfo" enableCountByExample="false" enableUpdateByExample ="false" enableDeleteByExample="false" enableSelectByExample ="false" selectByExampleQueryId="false" ></table >

    </context >

</generatorConfiguration>
View Code

log4j.properties

log4j.rootLogger = DEBUG, Console

# 输出到控制台
log4j.appender.Console = org.apache.log4j.ConsoleAppender
log4j.appender.Console.layout = org.apache.log4j.PatternLayout
log4j.appender.Console.layout.ConversionPattern = %d [%t] %-5p [%c] - %m%n

log4j.logger.java.sql.ResultSet=INFO
log4j.logger.org.apache=INFO
log4j.logger.java.sql.Connection=DEBUG
log4j.logger.java.sql.Statement=DEBUG
log4j.logger.java.sql.PreparedStatement=DEBUG
View Code

mybaits-config.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
        PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-config.dtd">

<configuration>
    <settings>
        <setting name="logImpl" value="LOG4J"/>
    </settings>
</configuration>
View Code

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.7.RELEASE</version>
        <relativePath/>
    </parent>


    <groupId>com.example</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>demo</name>
    <description>Demo project for Spring Boot</description>
    <properties>
        <java.version>1.8</java.version>
    </properties>


    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>

        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid-spring-boot-starter</artifactId>
            <version>1.1.10</version>
        </dependency>


        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>1.3.1</version>
        </dependency>

        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>

        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
            <version>2.3</version>
        </dependency>

        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>2.3</version>
        </dependency>

        <dependency>
            <groupId>org.mybatis.generator</groupId>
            <artifactId>mybatis-generator-core</artifactId>
            <version>1.3.5</version>
        </dependency>

        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>2.5</version>
        </dependency>

        <dependency>
            <groupId>joda-time</groupId>
            <artifactId>joda-time</artifactId>
            <version>2.9.9</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>

        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.48</version>
        </dependency>

        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>RELEASE</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.mybatis.generator</groupId>
                <artifactId>mybatis-generator-maven-plugin</artifactId>
                <version>1.3.6</version>
                <configuration>
                    <verbose>true</verbose>
                    <overwrite>true</overwrite>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>

        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.yml</include>
                    <include>**/*.xml</include>
                </includes>
                <filtering>false</filtering>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/*.yml</include>
                    <include>**/*.properties</include>
                    <include>**/*.xml</include>
                </includes>
                <filtering>false</filtering>
            </resource>
        </resources>

    </build>
</project>
View Code

 

标签:xml,Springboot,配置文件,spring,boot,Mybits,org,log4j,starter
来源: https://www.cnblogs.com/wangzhaojun1670/p/16153762.html

专注分享技术,共同学习,共同进步。侵权联系[admin#icode9.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有