国产成人精品18p,天天干成人网,无码专区狠狠躁天天躁,美女脱精光隐私扒开免费观看

SpringBoot環(huán)境配置知識總結

發(fā)布時(shí)間:2021-07-05 18:40 來(lái)源:腳本之家 閱讀:0 作者:gaoz666 欄目: 開(kāi)發(fā)技術(shù)

目錄

一、pom文件配置

<!-- SpringBoot的父級依賴(lài)。只有設置了parent標簽,項目才是SpringBoot項目  -->
<parent>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-parent</artifactId>
	<version>2.2.2.RELEASE</version>
</parent>

<dependencies>
   <!-- web啟動(dòng)器,加載web環(huán)境所需要的依賴(lài) -->
   <dependency>
   		<groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <!-- mybatis 集成 -->
    <dependency>
        <groupId>org.mybatis.spring.boot</groupId>
        <artifactId>mybatis-spring-boot-starter</artifactId>
        <version>2.1.1</version>
    </dependency>
    <!-- springboot 分頁(yè)插件 -->
    <dependency>
        <groupId>com.github.pagehelper</groupId>
        <artifactId>pagehelper-spring-boot-starter</artifactId>
        <version>1.2.13</version>
    </dependency>
    <!-- mysql 驅動(dòng) -->
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
    </dependency>
    <!-- c3p0 數據源 -->
    <dependency>
        <groupId>com.mchange</groupId>
        <artifactId>c3p0</artifactId>
        <version>0.9.5.5</version>
    </dependency>
    <!-- Freemarker Starter -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-freemarker</artifactId>
    </dependency>
    <!-- Thymeleaf Starter -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>
    <!-- JavaMail -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-mail</artifactId>
    </dependency>
    <!-- AOP -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-aop</artifactId>
    </dependency>
    <!-- Log -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-logging</artifactId>
    </dependency>
    <!-- tomcat -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>
    <!-- 為使用StringUtils工具類(lèi) -->
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
    </dependency>
    <!-- API文檔 -->
    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger2</artifactId>
        <version>2.9.2</version>
    </dependency>
    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger-ui</artifactId>
        <version>2.9.2</version>
    </dependency>
    <!-- DevTools 的坐標 -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <!--當前這個(gè)項目被繼承之后,這個(gè)不向下傳遞-->
        <optional>true</optional>	
    </dependency>
    <!-- SpringBoot單元測試 -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
    </dependency>
    <!-- Ehcache -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-cache</artifactId>
    </dependency>
    <dependency>
        <groupId>net.sf.ehcache</groupId>
        <artifactId>ehcache</artifactId>
    </dependency>
    
</dependencies>

<!-- SpringBoot項目的打包插件 -->
<build>
    <finalName>springboot</finalName>
	<plugins>
  	<plugin>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-maven-plugin</artifactId>
    </plugin>
    <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <configuration>
            <fork>true</fork><!-- 如果沒(méi)有該配置,熱部署的devtools不生效 -->
        </configuration>
    </plugin>
  </plugins>
</build>

相關(guān)starter系列坐標參考:

二、yml文件配置

yml文件放在resources目錄下

## 端口號  上下文路徑
server:
  port: 8989
  servlet:
    context-path: /mvc

## 數據源配置
spring:
  datasource:
    type: com.mchange.v2.c3p0.ComboPooledDataSource
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://127.0.0.1:3306/hr
    username: root
    password: root
    
  freemarker:
    suffix: .ftl
    content-type: text/html  #響應格式
    charset: UTF-8
    template-loader-path: classpath:/views/
    
  ## 熱部署配置
  devtools:
    restart:
      enabled: true
      # 設置重啟的目錄,添加目錄的文件需要restart
      additional-paths: src/main/java
      # 解決項目自動(dòng)重新編譯后接口報404的問(wèn)題
      poll-interval: 3000
      quiet-period: 1000
      
  ## Ehcache緩存配置
  cache:
    ehcache:
      config: classpath:ehcache.xml
    
## mybatis 配置
mybatis:
  #映射文件的存放路徑
  mapper-locations: classpath:/mappers/*.xml
  type-aliases-package: com.xxxx.springboot.po
  configuration:
    ## 下劃線(xiàn)轉駝峰配置
    map-underscore-to-camel-case: true

## pageHelper
pagehelper:
  helper-dialect: mysql

## 顯示dao 執行sql語(yǔ)句
logging:
  level:
    com:
      xxxx:
        dao: debug

三、SQL映射文件配置

sql映射文件路徑在"resources/mappers/"下

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.xxxx.dao.UserMapper">
    
</mapper>

四、ehcahe.xml 文件

配置在resources下

<ehcache name="mycache">
  	<!-- 
		如果不使用磁盤(pán)存儲,只需要將diskStore注釋掉即可;
		如果使用,需要在ehcache.xml文件中的ehcahce元素下的定義一個(gè)diskStore元素并指定其path屬性。 
	-->
    <diskStore path="C:\java\cache"/>
    <!--
        name:緩存名稱(chēng)。
        maxElementsInMemory:緩存最大數目
        maxElementsOnDisk:硬盤(pán)最大緩存個(gè)數。
        eternal:對象是否永久有效,一但設置了,timeout將不起作用。
        overflowToDisk:是否保存到磁盤(pán),當系統宕機時(shí)
        timeToIdleSeconds:設置對象在失效前的允許閑置時(shí)間(單位:秒)。
        	僅當eternal=false對象不是永久有效時(shí)使用,可選屬性,默認值是0,表示可閑置時(shí)間無(wú)窮大。
        timeToLiveSeconds:設置對象在失效前允許存活時(shí)間(單位:秒)。
            最大時(shí)間介于創(chuàng  )建時(shí)間和失效時(shí)間之間。
			僅當eternal=false對象不是永久有效時(shí)使用,默認是0,也就是對象存活時(shí)間無(wú)窮大。
        diskPersistent:是否緩存虛擬機重啟期數據 
			Whether the disk store persists between restarts of the Virtual Machine. 			 The default value is false.
        diskSpoolBufferSizeMB:這個(gè)參數設置DiskStore(磁盤(pán)緩存)的緩存區大小。
			默認是30MB。每個(gè)Cache都應該有自己的一個(gè)緩沖區。
        diskExpiryThreadIntervalSeconds:磁盤(pán)失效線(xiàn)程運行時(shí)間間隔,默認是120秒。
        memoryStoreEvictionPolicy:當達到maxElementsInMemory限制時(shí),會(huì )根據指定的策略去清理內存
             默認策略是LRU(最近最少使用)。你可以設置為FIFO(先進(jìn)先出)或是LFU(較少使用)。
        clearOnFlush:內存數量最大時(shí)是否清除。
        memoryStoreEvictionPolicy:
			可選策略有:
				LRU(最近最少使用,默認策略)
					Less Frequently Used,就是例子中使用的策略,就是一直以來(lái)最少被使用的。
				FIFO(先進(jìn)先出)
					first in first out,這個(gè)是大家最熟的,先進(jìn)先出。
				LFU(最少訪(fǎng)問(wèn)次數)
					Least Recently Used,最近最少使用的。
					緩存的元素有一個(gè)時(shí)間戳,當緩存容量滿(mǎn)了,而又需要騰出地方來(lái)緩存新的元素的時(shí)候,
					那么現有緩存元素中時(shí)間戳離當前時(shí)間最遠的元素將被清出緩存。
        -->
    <defaultCache
            maxElementsInMemory="10000"
            eternal="false"
            timeToIdleSeconds="120"
            timeToLiveSeconds="120"
            maxElementsOnDisk="10000000"
            diskExpiryThreadIntervalSeconds="120"
            memoryStoreEvictionPolicy="LRU">
    </defaultCache>

    <cache
            name="users"
            eternal="false"
            maxElementsInMemory="100"
            overflowToDisk="false"
            diskPersistent="false"
            timeToIdleSeconds="0"
            timeToLiveSeconds="300"
            memoryStoreEvictionPolicy="LRU"/>
</ehcache>

到此這篇關(guān)于SpringBoot環(huán)境配置知識總結的文章就介紹到這了,更多相關(guān)SpringBoot環(huán)境配置內容請搜索腳本之家以前的文章或繼續瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng )、來(lái)自互聯(lián)網(wǎng)轉載和分享為主,文章觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權請聯(lián)系QQ:712375056 進(jìn)行舉報,并提供相關(guān)證據,一經(jīng)查實(shí),將立刻刪除涉嫌侵權內容。

99热门精品一区二区三区无码| 丰满女人又爽又紧又丰满| 亚洲无线码在线一区观看| 伊人久久大香线蕉AV网禁呦| 亚洲人成手机电影网站| 影音先锋色中色|