Springboot文件结构和配置文件

1.文件结构

| -demo1-------------------------------------项目名称                  
|  | -.idea
|  |  | -libraries
|  |  |  | -compiler.xml
|  |  |  |  -encodings.xml
|  |  |  |  -misc.xml
|  |  |  | -modules.xml
|  |  |  | -workspace.xml
|  | -.mvn
|  |  | -wrapper
|  |  |  | -maven-wrapper.jar
|  |  |  | -maven-wrapper.properties
|  |  -src-----------------------------------源代码文件目录
|  |  | -main
|  |  |  | -java-----------------------------目录下放置所有java文件的源代码文件
|  |  |  |  | -com.example.demo
|  |  |  |  |  | -DemoApplication------------主函数入口类
|  |  |  | -resources------------------------放置所有的配置文件,页面文件,静态资源文件
|  |  |  |  | -static
|  |  |  |  | -templates
|  |  |  |  | -application.properties--------配置文件
|  |  | -test--------------------------------测试功能文件目录
|  |  |  | -java
|  |  |  |  | com.example.demo
|  |  |  |  | | DemoApplicationTests---------测试类
| -.gitignore
| -demo1.iml
| -mvnw
| -mvnw.cmd
| -pom.xml----------------------------------Maven管理:源代码、配置文件、开发者的信息和角色、问题追踪系统、组织信息、项目授权、项目的url、项目的依赖关系等等
| -External Libraries 
| -Scartches and Consoles

2.配置文件

常用的配置文件主要有两个:

application.properties:各种配置,比如运行端口等,项目初始化后此文件是空的,需要自己添加配置,不配置默认8080.

pom.xml:Maven对各种包资源的管理

常见的application.properties

# 服务端口号
server.port=8088
# 应用名称,一般就是项目名称,这个名称在SpringCloud中比较关键
spring.application.name=customer
#指定当前的活动配置文件,主要用于多环境多配置文件的应用中
spring.profiles.active=dev
#配置在使用Thymeleaf做页面模板时的前缀,即页面所在路径
spring.thymeleaf.prefix=classpath:/templates/
#设置在使用Thymeleaf做页面模板时的后缀
spring.thymeleaf.suffix=.html
#设置在使用Thymeleaf做页面模板时是否启用缓存
spring.thymeleaf.cache=false
#设置静态资源的请求路径
spring.mvc.static-path-pattern=/**
#指定静态资源的路径
spring.resources.static-locations=classpath:/static/,classpath:/public/

server.servlet.context-path=/adapter
management.endpoints.web.exposure.include=*
management.endpoints.web.exposure.exclude=env,beans

spring.datasource.name=test
spring.datasource.url=jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=gbk&zeroDateTimeBehavior=convertToNull
spring.datasource.username=root
spring.datasource.password=123456
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.filters=stat
spring.datasource.maxActive=20
spring.datasource.initialSize=1
spring.datasource.maxWait=60000
spring.datasource.minIdle=1
spring.datasource.timeBetweenEvictionRunsMillis=60000
spring.datasource.minEvictableIdleTimeMillis=300000
spring.datasource.validationQuery=select 'x'
spring.datasource.testWhileIdle=true
spring.datasource.testOnBorrow=false
spring.datasource.testOnReturn=false
spring.datasource.poolPreparedStatements=true
spring.datasource.maxPoolPreparedStatementPerConnectionSize=20
spring.datasource.maxOpenPreparedStatements=20

mybatis.mapper-locations=classpath:mapping/*.xml
mybatis.type-aliases-package=com.example.bootdemo.model

mapper.mappers= com.example.bootdemo.dao
mapper.not-empty=false
mapper.identity=MYSQL

#pagehelper分页插件
pagehelper.helperDialect=mysql
pagehelper.reasonable=true
pagehelper.rowBoundsWithCount=true
pagehelper.supportMethodsArguments=true
pagehelper.offsetAsPageNum=true
pagehelper.returnPageInfo=check
#pagehelper.params=count=countSql

# Redis数据库索引(默认为0)
spring.redis.database=0
# Redis服务器地址
spring.redis.host=127.0.0.1
# Redis服务器连接端口
spring.redis.port=6379
# Redis服务器连接密码(默认为空)
spring.redis.password=123456
# 连接池最大连接数(使用负值表示没有限制)
spring.redis.jedis.pool.max-active=8
# 连接池最大阻塞等待时间(使用负值表示没有限制)
spring.redis.jedis.pool.max-wait=-1
# 连接池中的最大空闲连接
spring.redis.jedis.pool.max-idle=8
# 连接池中的最小空闲连接
spring.redis.jedis.pool.min-idle=0
# 连接超时时间(毫秒)
spring.redis.timeout=5000

 

pom.xml文件:常用的就是添加dependency节点,添加依赖项,maven会自动提示是否加载资源文件



    4.0.0

    com.example
    demo
    0.0.1-SNAPSHOT
    jar

    demo
    Demo project for Spring Boot
    
    
        org.springframework.boot
        spring-boot-starter-parent
        2.0.6.RELEASE
         
    
    
    
        UTF-8
        UTF-8
        1.8
    
    
    
        
        
            org.springframework.boot
            spring-boot-starter-web-services
        
        
        
            org.slf4j
            slf4j-log4j12
        
        
        
            org.springframework.boot
            spring-boot-starter-actuator
        
        
        
            org.springframework.boot
            spring-boot-starter-jdbc
        
        
        
            org.mybatis.spring.boot
            mybatis-spring-boot-starter
            1.3.2
        
        
        
            mysql
            mysql-connector-java
            runtime
        
        
        
            org.springframework.boot
            spring-boot-starter-tomcat
            provided
        
        
        
            org.springframework.boot
            spring-boot-starter-test
            test
        
        
        
            org.springframework.boot
            spring-boot-starter-data-redis
        
        
        
        
        
        
        
            com.github.pagehelper
            pagehelper
            5.1.3
        
        
        
            com.alibaba
            druid-spring-boot-starter
            1.1.0
        
        
            com.alibaba
            druid
            1.1.0
        
        
        
            org.apache.commons
            commons-lang3
        
        
        
        
            org.springframework.boot
            spring-boot-devtools
            true
        
        
        
            org.springframework.boot
            spring-boot-configuration-processor
        

        
            org.springframework.boot
            spring-boot-starter-freemarker
        
        
        
        
        
        
        
            com.alibaba
            fastjson
            1.2.47
        
        
            com.tencentcloudapi
            
            tencentcloud-sdk-java
            3.0.8
        
        
            dom4j
            dom4j
        
    
    
    
        
            
                org.springframework.boot
                spring-boot-maven-plugin
            
        
    



 

你可能感兴趣的:(Springcloud)