Springboot integration features: database linking (unused database connection pool), HTML page access, static resource storage calls, Hibernate Jpa, SpringBoot hot deployment, Lombok omit getSet method needs: Idea Install Lombok Plugin, return to front end unified Jackson time formatting
Springboot project creation steps:
Directory structure:
<?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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.1. RELEASE</version>
<relativePath/> <! -- lookup parent from repository -->
</parent>
<groupId>com.dist</groupId>
<artifactId>springbootdemo</artifactId>
<version>0.0.1 - the SNAPSHOT</version>
<packaging>war</packaging>
<name>springbootdemo</name>
<description>Demo project for Spring Boot</description>
<! -- Global variables -->
<properties>
<java.version>1.8</java.version>
<oracle.version>11.2.0.3</oracle.version>
<lombok.version>1.16.18</lombok.version>
<druid.version>1.0.14</druid.version>
</properties>
<dependencies>
<! --======== SpringBoot configuration start ===========-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<! -- Built-in tomcat for SpringBoot -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<! -- hibernate jpa-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<! Easy and fast access to static resources (images, HTML, etc.)-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<! -- Used in development stage: Springboot hot boot (hot deployment) : project has changed, automatic compilation: need to configure idea true to take effect -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<! --======= SpringBoot configuration end =========-->
<! -- Alibaba database connection pool :1 use druid connection pool, 2 configure in YML -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>${druid.version}</version>
</dependency>
<! -- Oracle Database driver -->
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>${oracle.version}</version>
</dependency>
<! JavaBean get, set, toString, hashCode, equals, etc.
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<! -- Bind JDK version and package encoding format UTF-8 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<target>${java.version}</target>
<source>${java.version}</source>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<! Skip tests while packing -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
</build>
</project>
Copy the code
application.yml
server:
port: 8089 # tomcat port number
servlet:
context-path: /springboot # project root pathSpring: datasource: URL: JDBC :oracle:thin:@127.0.0.1:1521:orcl username: oms password: pass driver-class-name: JDBC :oracle:thin:@127.0.0.1:1521:orcl username: oms password: pass driver-class-name: oracle.jdbc.driver.OracleDriver jpa: hibernate: ddl-auto: update show-sql:true
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8
serialization:
write-dates-as-timestamps: false
thymeleaf:
prefix: classpath:/templates/
Copy the code
Jackson solved the time format problem when returning to the front end