Quick initialization of spring boot monomer project based on tyboot

Quick initialization of spring boot monomer project based on tyboot

tyboot source code:

gitee

github

tybootdemo source code of sample project

tybootdemo

Project directory structure:

The package name is defined by itself,;

The controller and face directories are in the contract directory structure. Consistency is recommended

It is recommended to use multi environment configuration for configuration files. When starting, add the parameter spring.profiles.active as follows:

Run-->Edit Configurations...

pom.xml file content:

Tyboot packages are placed on personal private servers and can be used temporarily. It is recommended to clone the source code of tyboot and package it into your own private servers

<?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>org.typroject</groupId>
    <artifactId>tybootdemo</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>

    <name>tybootdemo</name>
    <description>tybootdemo</description>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <tyboot.version>1.1.20Ty-SNAPSHOT</tyboot.version>
    </properties>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.6.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <dependencies>

        <!-- Quote tyboot Core package start -->
        <dependency>
            <groupId>org.typroject</groupId>
            <artifactId>tyboot-core-foundation</artifactId>
            <version>${tyboot.version}</version>
        </dependency>

        <dependency>
            <groupId>org.typroject</groupId>
            <artifactId>tyboot-core-restful</artifactId>
            <version>${tyboot.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.typroject</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.typroject</groupId>
            <artifactId>tyboot-core-auth</artifactId>
            <version>${tyboot.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.typroject</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.typroject</groupId>
            <artifactId>tyboot-core-rdbms</artifactId>
            <version>${tyboot.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.typroject</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.typroject</groupId>
            <artifactId>tyboot-component-cache</artifactId>
            <version>${tyboot.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.typroject</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-data-redis</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!-- Quote tyboot Core package end -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-redis</artifactId>
            <version>1.4.5.RELEASE</version>
        </dependency>

    </dependencies>

    <!-- Currently used springboot Version 2.1.6.RELEASE -->
    <dependencyManagement>
        <dependencies>
            <dependency>
                <!-- Import dependency management from Spring Boot -->
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>2.1.6.RELEASE</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <!--  tyboot My bag is in my private service,Can be used temporarily,It is suggested that tyboot After the source code is cloned, package it into your own private server -->
    <repositories>

        <repository>
            <id>maven-public</id>
            <name>maven-public</name>
            <url>http://repo.typroject.org:8081/repository/maven-public/</url>
        </repository>
        <repository>
            <id>maven-snapshot</id>
            <name>maven-snapshot</name>
            <url>http://repo.typroject.org:8081/repository/maven-snapshots/</url>
        </repository>

    </repositories>

    <pluginRepositories>
        <pluginRepository>
            <id>maven-public</id>
            <name>maven-public</name>
            <url>http://repo.typroject.org:8081/repository/maven-public/</url>
        </pluginRepository>
    </pluginRepositories>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>

        </plugins>
    </build>
</project>
application.properties file content:

Multi environment configuration is recommended

spring.application.name=tybootdemo
server.port=30010
server.servlet.context-path=/demo

server.compression.enabled=true
server.compression.mime-types=application/json,application/xml,text/html,text/xml,text/plain
#2048 byte s by default
server.compression.min-response-size=2048

#spring.jackson.default-property-inclusion=non_null
logging.config=classpath:logback-${spring.profiles.active}.xml

# mybatis_config
mybatis-plus.mapper-locations=classpath:mapper/*Mapper.xml
mybatis-plus.type-aliases-package=org.typroject.*.*.face.*.orm.entity
application-dev.properties file contents:

The database and cache configuration will be used in the next demonstration

# jdbc_config
spring.datasource.url=jdbc:mysql://192.168.1.212:3306/tybootdemo?characterEncoding=utf8&serverTimezone=Asia/Shanghai
spring.datasource.username=tybootdemo
spring.datasource.password=tybootdemo
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
#not support for spring-boot v1.5+, use org.apache.tomcat.jdbc.pool.DataSource by default.
spring.datasource.type=com.zaxxer.hikari.HikariDataSource
spring.datasource.hikari.minimum-idle=5
spring.datasource.hikari.maximum-pool-size=15
spring.datasource.hikari.auto-commit=true
spring.datasource.hikari.idle-timeout=30000
spring.datasource.hikari.pool-name=DatebookHikariCP
spring.datasource.hikari.max-lifetime=1800000
spring.datasource.hikari.connection-timeout=30000
spring.datasource.hikari.connection-test-query=SELECT 1

# REDIS (RedisProperties)
spring.redis.database=10
spring.redis.host=192.168.1.212
spring.redis.port=6379
spring.redis.password=xxxxx
spring.redis.timeout=0
logback-dev.xml file content
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false">
    <!-- console output  -->
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
            <!--Format output:%d Represents the date,%thread Represents the thread name,%-5level: Level 5 character width from left%msg: Log messages,%n Is line break-->
            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
        </encoder>
    </appender>
    <!--myibatis log configure-->
    <logger name="com.apache.ibatis" level="TRACE"/>
    <logger name="java.sql.Connection" level="DEBUG"/>
    <logger name="java.sql.Statement" level="DEBUG"/>
    <logger name="java.sql.PreparedStatement" level="DEBUG"/>

    <logger name="org.typroject" level="DEBUG"/>
    <logger name="org.springframework" level="DEBUG"/>
    <logger name="com.baomidou" level="DEBUG"/>

    <!-- Log output level -->
    <root level="DEBUG">
        <appender-ref ref="STDOUT"/>
    </root>
</configuration>

Now that the project initialization has been completed, you can further use all the core functions of tyboot, including

No sql coding experience

Tenant based data isolation mechanism

Data cache

Request frequency limit based on simple fixed window

Request interception extension based on interceptor

Error handling and exception definition

Unified request context

Uniform return format

Login authentication method extension

Authentication mechanism

Interface I / O encryption

Convenient tools

Local multi account login

Tags: Programming Spring Maven Redis xml

Posted on Mon, 04 May 2020 09:56:40 -0400 by dunn_cann