SpringBoot启动项目

springboot比ssm搭建方便很多,也快很多,小编这台电脑启动ssm项目最起码都要几分钟,springboot就几秒中。

小编在这里就写个笔记,以后写springboot的项目就不需要找以前的配置文件了

pom.xml

<packaging>war</packaging>
    <!--依赖springboot的父工程,其实它是一个maven项目-->
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.2.RELEASE</version>
    </parent>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis-reactive</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>io.projectreactor</groupId>
            <artifactId>reactor-test</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- 通用mapper -->
        <dependency>
            <groupId>tk.mybatis</groupId>
            <artifactId>mapper-spring-boot-starter</artifactId>
            <version>2.1.5</version>
        </dependency>
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>1.2.0</version>
        </dependency>

        <!--分页组件-->
        <dependency>
            <groupId>com.github.pagehelper</groupId>
            <artifactId>pagehelper-spring-boot-starter</artifactId>
            <version>1.2.12</version>
        </dependency>

        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid-spring-boot-starter</artifactId>
            <version>1.1.21</version>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.10</version>
        </dependency>

        <!--freemaker,thymeleaf-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-freemarker</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
        <dependency>
            <groupId>com.vaadin.external.google</groupId>
            <artifactId>android-json</artifactId>
            <version>0.0.20131108.vaadin1</version>
            <scope>compile</scope>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

 

 

application.yml

# 配置服务端口
server:
    port: 8080
spring:
    # 配置数据相关信息
    datasource:
        type: com.alibaba.druid.pool.DruidDataSource
        # 数据库账号
        username: root
        # 数据库密码
        password: root
        #数据库路径
        url: jdbc:mysql://localhost:3306/blog?useUnicode=true&characterEncoding=utf-8
        driver-class-name: com.mysql.jdbc.Driver

    # freemaker配置(配置文件访问路径)
    freemarker:
        suffix: .html
        template-loader-path: classpath:/templates/

    #配置时区
    jackson:
        time-zone: GMT+8
        date-format: yyyy-MM-dd HH:mm:ss
        # 解决返回long行的时候精度丢失的问题
        generator:
            write-numbers-as-strings: true
            write-bigdecimal-as-plain: true

# 配置mybatis
mybatis:
    # 实体类的文件夹
    type-aliases-package: blog.model
    # dao层的文件夹
    mapper-locations: classpath:dao/login/*.xml
    # 驼峰映射
    configuration:
        map-underscore-to-camel-case: true

# 配置分页
pagehelper:
    # 标识是哪种数据库
    helper-dialect: mysql

MySpringBootApplication.java

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import tk.mybatis.spring.annotation.MapperScan;

// 启动类的注解 此注解是一个复合注解 ,是由三个构成
@SpringBootApplication
//这里是tkd额mappercan
//搜索dao层
@MapperScan("blog.dao")
public class MySpringBootApplication {

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

}

 

这时点击启动就行了

本站资源除特别声明外,转载文章请声明文章出处
东泰博客 » SpringBoot启动项目

发表评论