Springboot从入门到精通
2018-03-16 11:38
253 查看
本系列教程将持续更新Java现在最热门的框架spring boot,比起传统的springmvc,springboot无疑是更加简化了我们的开发过程。它封装了一些我们常用的配置,习惯优于配置,而且还内嵌了tomcat,大大的提高了我们的开发效率。
下面我们就从零开始搭建一个springboot项目吧。
打开我们的工具Intellij IDEA,依次点击file -->> new -->> project -->> ,然后再弹出的界面中选择jdk版本(1.8)和maven项目(注意:必须使用maven项目,因为它用到的很多依赖需要maven去为我们下载)
点击next下一步,在界面中填写父工程的artifactid和groupid和version继续下一步
选择项目存放的物理路径然后点击finish。
1.添加spring io的依赖,替我们管理版本。
打开spring的官网,https://spring.io/;选择peojects点击spring io platform项目
下拉至quick start,选择ga版(相当于稳定版)的依赖。将其复制到我们的项目中。
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.spring.platform</groupId>
<artifactId>platform-bom</artifactId>
<version>Brussels-SR7</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>2.添加spring cloud的依赖,替我们管理项目。
方法与上面类似,选择其中最新的GA版将依赖加入到io的下面即可
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Edgware.SR2</version>
<type>pom</type>
<scope>import&l
4000
t;/scope>
</dependency>3.修改父工程为pom工程,只做版本管理。配置maven编译插件和jdk编译版本为1.8,最终父工程的pom文件如下。<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion>
<groupId>com.cfcc</groupId>
<artifactId>cfcc-parent</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<!--所有springboot工程都需要继承这个父工程-->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
</parent>
<!-- 管理工程的版本 -->
<properties>
<cfcc.version>1.0-SNAPSHOT</cfcc.version>
</properties>
<!-- 管理版本 -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.spring.platform</groupId>
<artifactId>platform-bom</artifactId>
<version>Brussels-SR7</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Edgware.SR2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
<modules>
<module>../cfcc-core</module>
<module>../cfcc-app</module>
<module>../cfcc-browser</module>
<module>../cfcc-demo</module>
</modules>
</project>
至此我们的项目的父工程搭建完毕。下一章节将继续搭建项目的各个子模块。
下面我们就从零开始搭建一个springboot项目吧。
打开我们的工具Intellij IDEA,依次点击file -->> new -->> project -->> ,然后再弹出的界面中选择jdk版本(1.8)和maven项目(注意:必须使用maven项目,因为它用到的很多依赖需要maven去为我们下载)
点击next下一步,在界面中填写父工程的artifactid和groupid和version继续下一步
选择项目存放的物理路径然后点击finish。
1.添加spring io的依赖,替我们管理版本。
打开spring的官网,https://spring.io/;选择peojects点击spring io platform项目
下拉至quick start,选择ga版(相当于稳定版)的依赖。将其复制到我们的项目中。
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.spring.platform</groupId>
<artifactId>platform-bom</artifactId>
<version>Brussels-SR7</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>2.添加spring cloud的依赖,替我们管理项目。
方法与上面类似,选择其中最新的GA版将依赖加入到io的下面即可
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Edgware.SR2</version>
<type>pom</type>
<scope>import&l
4000
t;/scope>
</dependency>3.修改父工程为pom工程,只做版本管理。配置maven编译插件和jdk编译版本为1.8,最终父工程的pom文件如下。<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion>
<groupId>com.cfcc</groupId>
<artifactId>cfcc-parent</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<!--所有springboot工程都需要继承这个父工程-->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
</parent>
<!-- 管理工程的版本 -->
<properties>
<cfcc.version>1.0-SNAPSHOT</cfcc.version>
</properties>
<!-- 管理版本 -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.spring.platform</groupId>
<artifactId>platform-bom</artifactId>
<version>Brussels-SR7</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Edgware.SR2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
<modules>
<module>../cfcc-core</module>
<module>../cfcc-app</module>
<module>../cfcc-browser</module>
<module>../cfcc-demo</module>
</modules>
</project>
至此我们的项目的父工程搭建完毕。下一章节将继续搭建项目的各个子模块。
相关文章推荐
- Spring boot入门实例 简易登录(精通Spring+4.x++企业应用开发实战 学习笔记二)
- SpringBoot从入门到精通
- spring boot从入门到精通
- Spring Boot从入门到精通课程
- 一个资深程序员教你jvm,redis,spring boot,dubbo,tomcat入门到精通
- SPRING-BOOT 教程,从入门到精通
- SpringBoot-从入门到放弃(二) 开发环境的搭建
- SpringBoot入门-13(springboot配置使用YML)
- springboot快速入门(二)——项目属性配置
- Spring-boot的入门创建
- SpringBoot入门系列篇(四):使用SpringBoot创建定时任务
- spring boot web 入门
- spring boot + vue + element-ui全栈开发入门——主页面开发
- spring boot最新教程(一):入门程序Hello World的编写
- Spring Boot (一)快速入门
- springboot--环境搭建与入门小例子
- Spring Boot入门之HelloWorld
- Spring Boot 快速入门实战(三)全局异常处理
- Spring Boot 入门小目标 1 --- 先来试着写个 Hello World