SpringBoot:我是怎样创建一个springboot项目的?

对于初学springboot的同学来说,可以试着用spring initializr来创建springboot项目,然后点击web,选择spring web就可以了。
在这里插入图片描述
在这里插入图片描述

但是 在创建分布式项目的时候,想要创建一个spring boot项目,有的时候编辑器反应不过来,不能自动加入到spring管理,所以我习惯使用创建maven的方式来创建springboot项目。

流程如下;
右击项目,然后选择new,module
在这里插入图片描述
直接创建maven空项目即可,点击next
在这里插入图片描述
填写相关信息,点击finish
在这里插入图片描述
进来之后是这样子的,你们不要管其他的module,只看mybatis-generator-code5
在这里插入图片描述
我们在pom.xml 中加入 spring-boot的依赖

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

因为是多模块项目,所以他会去找父项目包的版本,所以这里面没有版本
在这里插入图片描述

然后我们在resource里面新建配置文件 application.yml,内容就设置端口
在这里插入图片描述
配置启动类,随便创建一个类,使用@SpringBootApplication注解,写main函数,里面使用SpringApplication.run 创建入口
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_41288824/article/details/109225908