- 使用IDEA搭建第一个SpringBoot程序
- SpringBoot —— 搭建SpringBoot+Maven
- 2019-04-11 使用IDEA创建SpringBoot项目
- 多模块 SpringBoot 种子工程搭建 (一)
- SpringBoot系列—2.SpringBoot拦截器篇
- SpringBoot系列—3.SpringBoot Redis篇
- SpringBoot系列—5.SpringBoot 整合Myba
- SpringBoot系列—4.SpringBoot 整合Myba
- SpringBoot系列—1.IDEA搭建SpringBoot框
- [ERROR]element select is not all
本文使用idea2018、jdk8、tomcat8.0、mysql、mybatis进行搭建 、作为初学者在这里记录自己搭建springboot的过程。
在这里说明下 使用idea 搭建会省略很多步骤 对比 eclipse 会有很大不同记得注意区分
jdk、maven、tomcat 在idea中如何设置请自行百度
1.使用idea创建一个项目:


在idea 下面选项 Web中 会有 web选项记得有的勾选上



到此搭建一个空的springboot项目 就成功了
2..进行扩展spring项目
找到 pom.xml 打开

此处便是lib包引用 我们加上以下代码
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web-services</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
<version>2.1.4.RELEASE</version>
</dependency>
写完后 编译器 在右下角会提示 导入修改
成功后创建 类 并写返回值进行测试、

然后在启动类上添加注解
@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class}) //忽略数据库配置

在启动类上点击 “播放” 按钮启动项目,并在浏览器中输入http://127.0.0.1:8080/test/getValue

至此我们一个基础的项目就搭建完成了。
3.第一个hollo world
spring boot 集成了很简化的方式进行指定包名
在resources 中新建 templates(html)、static(静态资源css,img等)文件夹

在templates 下新建test 文件 并在test文件夹下新建 index.html

在TestController中添加方法
@RequestMapping("/index")
public void index() {
}
启动项目 在浏览器中输入 http://127.0.0.1:8080/test/index

下一章记录自己 如何完成 mybatis + mysql 并实现部署
网友评论