Spring Boot构建项目

1.使用IDEA Spring Initializr构建项目

2.pom.xml



    4.0.0

    com.wfc.web
    Test
    0.0.1-SNAPSHOT
    jar
   
    

    Test
    Demo project for Spring Boot

    
        org.springframework.boot
        spring-boot-starter-parent
        1.4.2.RELEASE
         
    

    
        UTF-8
        UTF-8
        1.8
    

    
        
            org.springframework.boot
            spring-boot-starter
            
                
                    org.springframework.boot
                    spring-boot-stater-logging
                
            
        

        
            org.springframework.boot
            spring-boot-starter-test
            test
        
        
            org.springframework.boot
            spring-boot-starter-web
            
                
                    log4j-over-slf4j
                    org.slf4j
                
            
        

        
            org.springframework.boot
            spring-boot-starter-redis
        

        
            org.springframework.boot
            spring-boot-starter-data-mongodb
        


        
            org.codehaus.groovy
            groovy-all
            2.4.7
        

        
        
            mysql
            mysql-connector-java
            5.1.29
        

        
            org.mybatis.spring.boot
            mybatis-spring-boot-starter
            1.1.1
        

        
            org.apache.commons
            commons-lang3
            3.1
        

        
        
            com.alibaba
            druid
            1.0.16
        

        
            com.aliyun.oss
            aliyun-sdk-oss
            2.2.1
        

        
            org.json
            json
            20090211
        

        
            com.google.code.morphia
            morphia
            0.104
        
         
        
            
            
            
        
    

    
        
            
                org.springframework.boot
                spring-boot-maven-plugin
            
            
            
                org.codehaus.gmavenplus
                gmavenplus-plugin
                1.5
                
                    
                        
                            addSources
                            addTestSources
                            generateStubs
                            compile
                            testGenerateStubs
                            testCompile
                            removeStubs
                            removeTestStubs
                        
                    
                
            
        
    



3.项目结构图

groovy目录下放.groovy,java目录下放.java

@SpringBootApplication
public class TestApplication {
//部署在外部Tomcat
//public class TestApplication extends SpringBootServletInitializer {

//    @Override
//    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
//        return builder.sources(TestApplication.class);
//    }

    public static void main(String[] args) {
        SpringApplication.run(TestApplication.class, args);
    }
}

application.yml

server:
  port: 8083
spring:
  devtools:
    livereload:
      enabled: true
  thymeleaf:
    cache: false
  freemarker:
    cache: false
  profiles:
    active: test#当前使用哪个配置(application-test.yml)
  datasource:
    name: spring
    driver-class-name: com.mysql.jdbc.Driver
    type: com.alibaba.druid.pool.DruidDataSource
    initialSize: 5
    minIdle: 5
    maxActive: 20
    maxWait: 60000
    timeBetweenEvictionRunsMillis: 60000
    minEvictableIdleTimeMillis: 300000
    validationQuery: SELECT 1 FROM DUAL
    testWhileIdle: true
    testOnBorrow: false
    testOnReturn: false
    poolPreparedStatements: true
    maxPoolPreparedStatementPerOonnectionSize: 20
    filters: stat, wall, log4j
  cache:
    #缓存名称
    cache-names: def
  # REDIS (RedisProperties)
  redis:
    pool:
      max-idle: 8 # pool settings ...
      min-idle: 0
      max-active: 8
      max-wait: -1
mybatis:
  mapper-locations: classpath:mapper/*.xml
  type-aliases-package: com.wfc.web.model
debug: true
logging:
  level: info

application-test.yml

spring:
  datasource:
    url:
    username:
    password:
  redis:
#    database:   # database name
    host:  # server host
    password: # server password
#    port:  # connection port
# mogodb
  data:
    mongodb:
      host: localhost
      port: 27017
      database: test

到此基本上完整啦!

你可能感兴趣的:(Spring Boot构建项目)