最近总是找springboot 的配置文件。不想每次创建新项目都找,所以记录一下。...

springboot  application.yml 配置文件。

server:
  port: 8080
  servlet:
    context-path: /

spring:
  application:
    name: springboot
  jpa:
    show-sql: true
    hibernate:
      ddl-auto: update
    properties:
      hibernate.format_sql: true
    open-in-view: false
    database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
  datasource:
    url: jdbc:mysql://127.0.0.1:3306/test1?autoReconnect=true
    username: root
    password: xxxxx
    tomcat:
      max-active: 4
      min-idle: 2
      initial-size: 2
    hikari:
      maximum-pool-size: 20
      minimum-idle: 5
  thymeleaf:
    mode: HTML
    encoding: UTF-8
    servlet:
      content-type: text/html
    cache: false
  mvc:
    view:
      prefix: classpath:/templates/
    static-path-pattern: /**
  resources:
    static-locations: classpath:/static/
    static-path-pattern: /**。 和 static-locations: classpath:/static/ 写好以后就可以在不用进入static页面访问里边的静态文件来。 而是直接写地址访问。 当然你可以自定义
@Configuration
@EnableWebMvc
public class WebConfig extends WebMvcConfigurerAdapter {


}
 
   

 还有一个最重要的pom.xml 看一下

 

    <parent>
        <groupId>org.springframework.bootgroupId>
        <artifactId>spring-boot-starter-parentartifactId>
        <version>2.1.6.RELEASEversion>
        <relativePath/> 
    parent>

    <properties>
        <project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8project.reporting.outputEncoding>
        <java.version>1.8java.version>
    properties>


    <dependencies>
        
        
        <dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-starter-webartifactId>
        dependency>

        <dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-starter-testartifactId>
            <scope>testscope>
        dependency>

        
        <dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-starter-data-jpaartifactId>
        dependency>

        
        <dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-devtoolsartifactId>
            <optional>trueoptional>
            <scope>truescope>
        dependency>

        
        <dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-starter-thymeleafartifactId>
        dependency>

        
        <dependency>
            <groupId>mysqlgroupId>
            <artifactId>mysql-connector-javaartifactId>
        dependency>
        <dependency>
            <groupId>org.jsongroupId>
            <artifactId>jsonartifactId>
            <version>20180813version>
        dependency>
    dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.bootgroupId>
                <artifactId>spring-boot-maven-pluginartifactId>
            plugin>
        plugins>
    build>

 

 

 

 

转载于:https://www.cnblogs.com/dipmight/p/11272985.html

你可能感兴趣的:(最近总是找springboot 的配置文件。不想每次创建新项目都找,所以记录一下。...)