SpringBoot入门

https://start.spring.io/

pom.xml



    4.0.0
    
    
        org.springframework.boot
        spring-boot-starter-parent
        2.1.5.RELEASE
    
    
    com.neuedu
    ssm
    1.0-SNAPSHOT
    ssm
    Demo project for Spring Boot
    
    
        UTF-8
        UTF-8
        1.8
    

    
        
            org.springframework.boot
            spring-boot-starter
        

        
            org.springframework.boot
            spring-boot-starter-web
        
        
        
            org.projectlombok
            lombok
            1.18.4
        
        
        
            mysql
            mysql-connector-java
            5.1.39
            runtime
        
        
        
            org.mybatis.spring.boot
            mybatis-spring-boot-starter
            1.3.2
        
        
        
            org.springframework.boot
            spring-boot-starter-data-redis
        
        
        
            com.alibaba
            fastjson
            1.2.47
        
        
        
            org.springframework.boot
            spring-boot-starter-test
            test
        
        
        
            org.springframework.boot
            spring-boot-test
        
        
    

    
        
            
                org.springframework.boot
                spring-boot-maven-plugin
            
        
    


res.main.java.com.neuedu.项目名.项目名Application.java

//此注解由@SpringBootConfiguration,@EnableAutoConfiguration,
//@ComponentScan有了spring配置,他就相当于一个spring容器,能自动扫描
//当前包或子包中的bean
@SpringBootApplication
//相当于mapper扫描器mapper.xml文件可写在resources下
@MapperScan("com.neuedu.hisdemo.mapper")
public class BootApplication {
    public static void main(String[] args) {
        SpringApplication.run(BootApplication.class,args);
    }
}

resources下application.yml

# 指定启动端口
server:
  port: 8089

#数据库连接参数
spring:
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8
    username: root
    password: root
#数据库连接池
    hikari:
      maximum-pool-size: 30
      minimum-idle: 10
      idle-timeout: 60000
#整合redis
  redis:
    host: 127.0.0.1
    port: 6379
    password: 123456
    jedis:
      pool:
        max-idle: 300
        max-wait: 1000
        max-active: 8
        min-idle: 10
#指定mapper文件路径 配置包中别名
mybatis:
  mapper-locations: classpath:mappers/*.xml
  type-aliases-package: com.neuedu.pojo
#指定日志打印级别
logging:
  level:
    com.neuedu.mapper: debug

src.java.com.neuedu.项目名.项目名ApplicationTests.java

@RunWith(SpringRunner.class)
@SpringBootTest
public class DemoApplicationTests {
    @Test
    public void contextLoads() {
    }
}

你可能感兴趣的:(SpringBoot入门)