Preliminary construction of springboot's background system

Architecture of springboot - based device management system

 

Tools used: idea

Database: mysql

Related technologies: shiro mybatis activemq , etc.

 

(1)  New project new project, idea has a special springboot plug-in , which is convenient for us to quickly create a springboot project, as shown in the figure below, click spring Initalizr   to select jdk , and then click next .


 

(2)  Then you can name your project, mainly Artifact and Group , as well as javaversion, the detailed configuration is as follows

 

(3)  The next step is actually to add dependencies , tick the main dependencies needed, and click next to complete the project creation in the first step. After the project is created, the corresponding dependencies will be automatically generated in the pom file .

 

(4) The overall effect of creating the project is shown in the figure

 

 

(5)  The application class is the main entrance of the springboot project . To start the project, you do not need to manually start the tomcat. You only need to start this class. Application.properties is the configuration file of springboot .

(6)  Next, let's connect to the database, use mybatis to make a query, first add the following configuration to the springboot configuration file

# jdbc_config
spring.datasource.url=jdbc\:mysql\://127.0.0.1\:3306/dhwooden?useUnicode\=true&characterEncoding\=utf-8&zeroDateTimeBehavior\=convertToNullspring.datasource.username
=rootspring.datasource.password
=rootspring.datasource.driver-class-name
=com.mysql.jdbc.Driverspring.datasource.dataSourceClassName
=#spring.datasource.type=com.zaxxer.hikari.HikariDataSource
spring.datasource.hikari.cachePrepStmts=true
spring.datasource.hikari.prepStmtCacheSize
=250spring.datasource.hikari.prepStmtCacheSqlLimit
=2048

 

The first four lines are the basic connection parameters of the database, url, username and password, and driver

The last four lines are for configuring the database connection pool. Here we use hikari as our database connection pool. Of course, we need to add dependencies to the pom file.

 

 <dependency><groupId>com.zaxxer</groupId><artifactId>HikariCP</artifactId><version>2.5.1</version></dependency>
    
    
    

(7)  After configuring the database connection, then configure mybatis, here we use mybatis-plus, which is equivalent to  the enhancement tool of Mybatis , and add the following configuration parameters to the springboot configuration file

#mybatis-plus
mybatis-plus.mapper-locations = classpath:com/ dhwooden /*/ mybatis /xml/*Mapper.xml mybatis-plus.typeAliasesPackage
= com.dhwooden .*. modal
##global-config:

#primary key type 0: "Database ID auto increment", 1: "User input ID", 2: "Global unique ID (numeric unique ID)", 3: "Global unique ID UUID"; mybatis-plus.global-config.id- type = 2 #Field
strategy 0: "Ignore judgment", 1: "Non-NULL judgment"), 2: "Non-null judgment"
mybatis-plus.global-config.field-strategy = 2 #Camel case
underline conversion
mybatis-plus. global-config.db-column-underline = true #Refresh
mapper debugging artifact
mybatis-plus.global-config.refresh-mapper=true #Database
capital and underscore conversion #capital-mode: true #Sequence interface implementation class configuration #key-generator: com.baomidou.springboot.xxx #Logical deletion configuration #logic-delete-value: 0 #logic-not-delete-value : 1 #implementation of custom filling strategy interface #meta-object-handler: com.baomidou.springboot.xxx #custom SQL injector #sql-injector: com.baomidou.springboot.xxx ##configuration:











mybatis-plus.configuration .map-underscore-to-camel-case = true mybatis-plus.configuration.cache-enabled
= false

 

The next step is to write the business layer , the modal layer, etc., which can be generated by the code generator of mybatis-plus . Due to the introduction of the Thymeleaf template engine, the front-end page uses html . Comments can leave a message, I am also a newbie.

 

 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324384967&siteId=291194637