美文网首页
idea如何新建springboot项目

idea如何新建springboot项目

作者: xiari1991 | 来源:发表于2020-06-06 17:26 被阅读0次

    方式一、 通过idea的Spring Initralizer

    1、

    new-->Project-->Spring Initralizer

    填写项目信息:
    Group:com.zb
    Artifact:zbook
    springboot version:2.0.4

    2、

    <dependency>
       <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-starter</artifactId>
    </dependency>
    

    改成

    <dependency>
       <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    

    3、

    此时项目结构


    image.png

    maven clean一下,右键ZbookApplication运行,项目就跑起来了,就是这么简单,真正做到了开箱即用。

    方式二、通过新建Maven配置依赖建立springboot项目

    1、new-->Project-->Maven,填写项目信息

    image.png
    image.png

    maven项目的目录结构


    image.png

    2、添加依赖

        <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>2.2.2.RELEASE</version>
        </parent>
        <properties>
            <spring-boot.version>2.2.2.RELEASE</spring-boot.version>
        </properties>
    
    
        <dependencies>
           
            <!-- boot-web 依赖 -->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
                <version>${spring-boot.version}</version>
            </dependency>
         </dependencies>
    

    刷新maven,加载依赖


    image.png

    3、新建application.properties,并配置端口号

    server.port=8007
    

    新建启动文件,和控制器文件


    image.png

    配置启动文件

    @SpringBootApplication
    public class TestApp {
    
        public static void main(String[] args) {
            SpringApplication.run(TestApp.class, args);
            System.out.println("启动成功");
        }
    }
    
    

    这是项目就建好了。

    相关文章

      网友评论

          本文标题:idea如何新建springboot项目

          本文链接:https://www.haomeiwen.com/subject/veowzhtx.html