zoukankan      html  css  js  c++  java
  • 使用idea创建springboot项目

    1.为什么要使用springboot

    springboot的框架优点:以下摘自spring官网对springboot的介绍;https://spring.io/projects/spring-boot

     Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications that you can "just run".

    We take an opinionated view of the Spring platform and third-party libraries so you can get started with minimum fuss. Most Spring Boot applications need very little Spring configuration.

    使用Spring Boot可以很容易的创建独立的,基于生产级别的基于Spring的应用程序,可以直接运行它。  我们可以很容易的使用它集成第三方的依赖,减少了不必要的麻烦。大多数Spring Boot应用程序只需要很少的Spring配置。

    Features(特点)

    • Create stand-alone Spring applications 创建独立的Spring应用程序

    • Embed Tomcat, Jetty or Undertow directly (no need to deploy WAR files)    直接嵌入了Tomcat,Jetty或Undertow(无需部署WAR包了)

    • Provide opinionated 'starter' dependencies to simplify your build configuration  提供了初始化的依赖,简化了配置

    • Automatically configure Spring and 3rd party libraries whenever possible  自动配置spring和第三方库

    • Provide production-ready features such as metrics, health checks and externalized configuration  提供生产环境的一些功能,例如指标,运行状况检查和外部配置

    • Absolutely no code generation and no requirement for XML configuration  完全没有代码生成,也不需要XML配置

    优点:

    (以下为网友总结的,其实和官网所说的是一样的,只是更加容易理解):

    • 使用Java或Groovy开发基于Spring的应用程序非常容易。
    • 它减少了大量的开发时间并提高了生产力。
    • 它避免了编写大量的样板代码,注释和XML配置。
    • Spring Boot应用程序与其Spring生态系统(如Spring JDBC,Spring ORM,Spring Data,Spring Security等)集成非常容易。
    • 它遵循“自用默认配置”方法,以减少开发工作量。
    • 它提供嵌入式HTTP服务器,如Tomcat,Jetty等,以开发和测试Web应用程序非常容易。
    • 它提供CLI(命令行界面)工具从命令提示符,非常容易和快速地开发和测试Spring Boot(Java或Groovy)应用程序。
    • 它提供了许多插件来开发和测试Spring启动应用程序非常容易使用构建工具,如Maven和Gradle。
    • 它提供了许多插件,以便与嵌入式和内存数据库工作非常容易。

    缺点

    • 将现有或传统的Spring Framework项目转换为Spring Boot应用程序是一个非常困难和耗时的过程。它仅适用于全新Spring项目。

    2.搭建springboot项目

    1.file->new->project 选择Spring Initializr创建项目,直接下一步

       

    2.填写groupid、artifactid、version等信息,然后点击下一步

     点击下一步

     左边根据需要配置,不需要直接点击下一步即完成sprint boot项目搭建

     3.然后在创建的项目的pom中添加springboot的依赖

     <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>2.2.1.RELEASE</version>
            <relativePath/> <!-- lookup parent from repository -->
        </parent>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </dependency>
        </dependencies>
    
        <properties>
            <java.version>1.8</java.version>
        </properties>
    
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter</artifactId>
            </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>
        </dependencies>
    
        <build>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                </plugin>
            </plugins>
        </build>

    4.使用spring官网创建springboot项目

    官网地址:https://start.spring.io/

    填写自己创建项目的信息,然后点击generate进行生成,会生成一个demo.zip的包,解压后,使用idea导入即可

    springboot下一章讲解启动类

  • 相关阅读:
    hdu2191(多重背包)
    hdu3664(递推dp)
    hdu2955(变形01背包)
    hdu1712(分组背包)
    hdu1114(完全背包)
    hdu4004(二分)
    hdu2870(dp求最大子矩阵)
    POJ 1979 Red and Black(水题,递归)
    POJ 1922 Ride to School(贪心+模拟)
    POJ 1182 食物链(种类并查集)
  • 原文地址:https://www.cnblogs.com/guanbin-529/p/11992806.html
Copyright © 2011-2022 走看看