s
spring boot配置
spring boot是免配置启动的 不用经过tomcat
但是要配置文件
spring.datasource.url=jdbc:oracle:thin:@127.0.0.1:1521:orcl
spring.datasource.username=JF190829
spring.datasource.password=JF190829
spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver
spring.freemarker.enabled=true
spring.freemarker.template-loader-path=classpath:/static/ //静态页面所在的位置
spring.freemarker.prefix=
spring.freemarker.suffix=.html //加上后缀
spring.freemarker.content-type=text/html
spring.freemarker.charset=UTF-8
spring.freemarker.settings.tag_syntax=auto_detect
server.port = 1998//配置的端口号
logging.level.org.berlin=debug
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
spring.jackson.time-zone=GMT+8
pagehelper.offsetAsPageNum=true
pagehelper.rowBoundsWithCount=true
pagehelper.pageSizeZero=false
pagehelper.reasonable=false
pagehelper.params=pageNum=pageHelperStart;pageSize=pageHelperRows;
pagehelper.supportMethodsArguments=false
在 resources包中配置application.properties文件
然后引入spring boot的所需要的jar包
<?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.2.4.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>spring_boot</groupId>
<artifactId>spring_boot_test</artifactId>
<version>0.0.1</version>
<name>spring_boot_test</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-web</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.4.0-atlassian-hosted</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.40</version>
</dependency>
<!-- 分页插件包 -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
<resources>
<resource>
<targetPath>${project.build.directory}/classes</targetPath>
<directory>src/main/java</directory>
<includes>
<include>**/*Mapper.xml</include>
</includes>
</resource>
<!--引入resources的资源文件 -->
<resource>
<targetPath> ${project.build.directory}/classes</targetPath>
<directory>src/main/resources</directory>
<includes>
<include>**</include>
</includes>
</resource>
</resources>
</build>
</project>
在src下面创建一个启动类
package com.zeyi;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
//启动类
@SpringBootApplication
public class ZeyiApplication {
public static void main(String[] args) {
SpringApplication.run(ZeyiApplication.class, args);
}
}
从启动类里面启动项目
在 resources包里面的static包中创建一个html页面
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
spring boot启动
</body>
</html>
在浏览器中访问自定义的端口 :1998
eg:http://localhost:1998/
默认访问的是index.html页面
基本启动完成