Upfront - backstage - environment building

1, Create pom project

Name: atcrowdfunding01-admin-parent
GroupId: com.atguigu.crowd

2, Create module: atcrowdfinding02 admin webui

atcrowdfunding02-admin-webui

3, Create module: atcrowdfinding03 admin component

 

 

4, Create module: atcrowdfunding 04 admin entity

 

5, Create module: atcrowdfinding05 common util

parent selects None

6, Create module: atcrowdfunding 06 common reverse

7, Establish dependency between projects

webui depends on component
component depends on entity
component depends on util

1. Right click in the pom file of atcrowdfunding 02 admin webui to add a dependency

<dependencies>
    <dependency>
        <groupId>com.atguigu.crowd</groupId>
        <artifactId>atcrowdfunding03-admin-component</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>
</dependencies>

2. Right click the pom file of atcrowdfunding 03 admin component to add a dependency. The operation steps are the same as above, and the screenshot is omitted

<dependencies>
    <dependency>
        <groupId>com.atguigu.crowd</groupId>
        <artifactId>atcrowdfunding04-admin-entity</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>com.atguigu.crowd</groupId>
        <artifactId>atcrowdfunding05-common-util</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>
</dependencies>

8, Create databases and tables

CREATE DATABASE `project_crowd` CHARACTER SET utf8;

use project_crowd;

drop table if exists t_admin;

create table t_admin
(
id int not null auto_increment, # Primary key
login_acct varchar(255) not null, # Login account
user_pswd char(32) not null, # Login password
user_name varchar(255) not null, # Nickname?
email varchar(255) not null, # mailing address
create_time char(19), # Creation time
primary key (id)
);

MyBatis reverse engineering based on Maven

pom configuration

    <!-- rely on MyBatis Core package-->
    <dependencies>
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis</artifactId>
            <version>3.2.8</version>
        </dependency>
    </dependencies>
    <!-- control Maven Configuration during build-->
    <build>
        <!-- Plug ins used in the construction process-->
        <plugins>
            <!-- Specific plug-ins, reverse engineering operations are in the form of plug-ins during the construction process-->
            <plugin>
                <groupId>org.mybatis.generator</groupId>
                <artifactId>mybatis-generator-maven-plugin</artifactId>
                <version>1.3.0</version>
                <!-- Plug in dependencies-->
                <dependencies>
                    <!-- Core dependence of reverse engineering-->
                    <dependency>
                        <groupId>org.mybatis.generator</groupId>
                        <artifactId>mybatis-generator-core</artifactId>
                        <version>1.3.2</version>
                    </dependency>
                    <!-- Database connection pool-->
                    <dependency>
                        <groupId>com.mchange</groupId>
                        <artifactId>c3p0</artifactId>
                        <version>0.9.2</version>
                    </dependency>
                    <!-- MySQL drive-->
                    <dependency>
                        <groupId>mysql</groupId>
                        <artifactId>mysql-connector-java</artifactId>
                        <version>8.0.18</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>

generatorConfig.xml

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>
    <!-- mybatis-generator:generate -->
    <context id="atguiguTables" targetRuntime="MyBatis3">
        <commentGenerator>
            <!-- Remove automatically generated comments or not true:yes;false:no-->
            <property name="suppressAllComments" value="true"/>
        </commentGenerator>
        <!--Database connection information: driver class, connection address, user name, password-->
        <jdbcConnection
                driverClass="com.mysql.cj.jdbc.Driver"
                connectionURL="jdbc:mysql://localhost:3306/project_crowd?serverTimezone=GMT%2B8&amp;useSSL=false&amp;useUnicode=true&amp;characterEncoding=utf8"
                userId="root"
                password="123456">
        </jdbcConnection>
        <!-- default false,hold JDBC DECIMAL and NUMERIC Type resolves to Integer,by true Shi Ba
        JDBC DECIMAL
        //And NUMERIC types resolve to Java. Math. BigDecimal -- >
        <javaTypeResolver>
            <property name="forceBigDecimals" value="false"/>
        </javaTypeResolver>
        <!-- targetProject:generate Entity Path to class-->
        <javaModelGenerator targetProject=".\src\main\java"
                            targetPackage="entity">
            <!-- enableSubPackages:Whether to let schema As suffix of package-->
            <property name="enableSubPackages" value="false"/>
            <!-- Spaces before and after values returned from the database are cleaned up-->
            <property name="trimStrings" value="true"/>
        </javaModelGenerator>
        <!-- targetProject:XxxMapper.xml Path to map file generation-->
        <sqlMapGenerator targetProject=".\src\main\java"
                         targetPackage="com.atguigu.crowd.mapper">
            <!-- enableSubPackages:Whether to let schema As suffix of package-->
            <property name="enableSubPackages" value="false"/>
        </sqlMapGenerator>
        <!-- targetPackage: Mapper Location of interface generation-->
        <javaClientGenerator type="XMLMAPPER"
                             targetProject=".\src\main\java"
                             targetPackage="com.atguigu.crowd.mapper">
            <!-- enableSubPackages:Whether to let schema As suffix of package-->
            <property name="enableSubPackages" value="false"/>
        </javaClientGenerator>
        <!-- Database table name and our entity Class mapping assignment-->
        <table tableName="t_admin" domainObjectName="Admin"/>
    </context>
</generatorConfiguration>

The header file of generator config.xml is marked in red at http://mybatis.org/dtd/mybatis-generator-config

Solution: red light bulb on the left, click Fetch external resource to solve

Error: Java does not support release 5. The Java version used for project compilation configuration is incorrect

Add an execution configuration for mybatis generator.

Similar to adding tomcat, enter the configuration pop-up window, click + OK, fill in the name of mybatis generator, select the directory D: \ ideaprojects \ atcrowdfunding 01 admin parent \ atcrowdfunding 06 common reverse, enter the command mybatis generator: generate, and click OK.

Select mybatis generator configuration and click execute

Parent project dependency management

<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.atguigu.crowd</groupId>
    <artifactId>atcrowdfunding01-admin-parent</artifactId>
    <packaging>pom</packaging>
    <version>1.0-SNAPSHOT</version>
    <modules>
        <module>atcrowdfunding02-admin-webui</module>
        <module>atcrowdfunding03-admin-component</module>
        <module>atcrowdfunding04-admin-entity</module>
    </modules>

    <properties>
        <!-- Declaration properties, for Spring Unified management of versions of-->
        <atguigu.spring.version>4.3.20.RELEASE</atguigu.spring.version>
        <!-- Declaration properties, for SpringSecurity Unified management of versions of-->
        <atguigu.spring.security.version>4.2.10.RELEASE</atguigu.spring.security.version>
    </properties>
    <dependencyManagement>
        <dependencies>
            <!-- Spring rely on-->
            <!-- https://mvnrepository.com/artifact/org.springframework/spring-orm -->
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-orm</artifactId>
                <version>${atguigu.spring.version}</version>
            </dependency>
            <!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-webmvc</artifactId>
                <version>${atguigu.spring.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-test</artifactId>
                <version>${atguigu.spring.version}</version>
            </dependency>
            <!-- https://mvnrepository.com/artifact/org.aspectj/aspectjweaver -->
            <dependency>
                <groupId>org.aspectj</groupId>
                <artifactId>aspectjweaver</artifactId>
                <version>1.9.2</version>
            </dependency>
            <!-- https://mvnrepository.com/artifact/cglib/cglib -->
            <dependency>
                <groupId>cglib</groupId>
                <artifactId>cglib</artifactId>
                <version>2.2</version>
            </dependency>
            <!-- Database dependence-->
            <!-- MySQL drive-->
            <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
                <version>8.0.18</version>
            </dependency>
            <!-- data source-->
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>druid</artifactId>
                <version>1.0.31</version>
            </dependency>
            <!-- MyBatis -->
            <dependency>
                <groupId>org.mybatis</groupId>
                <artifactId>mybatis</artifactId>
                <version>3.2.8</version>
            </dependency>
            <!-- MyBatis And Spring integration-->
            <dependency>
                <groupId>org.mybatis</groupId>
                <artifactId>mybatis-spring</artifactId>
                <version>1.2.2</version>
            </dependency>
            <!-- MyBatis Paging plug in-->
            <dependency>
                <groupId>com.github.pagehelper</groupId>
                <artifactId>pagehelper</artifactId>
                <version>4.0.0</version>
            </dependency>

            <!-- Journal-->
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
                <version>1.7.7</version>
            </dependency>
            <dependency>
                <groupId>ch.qos.logback</groupId>
                <artifactId>logback-classic</artifactId>
                <version>1.2.3</version>
            </dependency>
            <!-- Intermediate conversion packages for other logging frameworks-->
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>jcl-over-slf4j</artifactId>
                <version>1.7.25</version>
            </dependency>
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>jul-to-slf4j</artifactId>
                <version>1.7.25</version>
            </dependency>
            <!-- Spring Conduct JSON Data conversion dependency-->
            <dependency>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-core</artifactId>
                <version>2.9.8</version>
            </dependency>
            <dependency>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-databind</artifactId>
                <version>2.9.8</version>
            </dependency>
            <!-- JSTL Label Library-->
            <dependency>
                <groupId>jstl</groupId>
                <artifactId>jstl</artifactId>
                <version>1.2</version>
            </dependency>

            <!-- junit test-->
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>4.12</version>
                <scope>test</scope>
            </dependency>
            <!-- Introduce Servlet Related dependencies in container-->
            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>servlet-api</artifactId>
                <version>2.5</version>
                <scope>provided</scope>
            </dependency>
            <!-- JSP Page usage dependency-->
            <dependency>
                <groupId>javax.servlet.jsp</groupId>
                <artifactId>jsp-api</artifactId>
                <version>2.1.3-b06</version>
                <scope>provided</scope>
            </dependency>
            <!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
            <dependency>
                <groupId>com.google.code.gson</groupId>
                <artifactId>gson</artifactId>
                <version>2.8.5</version>
            </dependency>
            <!-- SpringSecurity Yes Web Application for permission management-->
            <dependency>
                <groupId>org.springframework.security</groupId>
                <artifactId>spring-security-web</artifactId>
                <version>4.2.10.RELEASE</version>
            </dependency>
            <!-- SpringSecurity To configure-->
            <dependency>
                <groupId>org.springframework.security</groupId>

                <artifactId>spring-security-config</artifactId>
                <version>4.2.10.RELEASE</version>
            </dependency>
            <!-- SpringSecurity Label Library-->
            <dependency>
                <groupId>org.springframework.security</groupId>
                <artifactId>spring-security-taglibs</artifactId>
                <version>4.2.10.RELEASE</version>
            </dependency>
        </dependencies>
    </dependencyManagement>
</project>

Keywords: Programming Mybatis Spring MySQL Java

Added by bacil on Tue, 21 Apr 2020 17:15:44 +0300