IDEA配置JDK
(1)安装JDEA 2017 和 JDK1.8 (步骤略)
(2)启动IDEA , 第一次启动会弹出如下窗口
(3)点击Configure 下拉菜单选择 Project Defaults -- Project Structure
(4)点击new -- jdk
IDEA配置maven本地仓库
本地仓库配置为课程配套的本地仓库
(1)解压课程提供的本地仓库到某目录(D:\reponsitory_boot),打开maven的配置文
件配置 conf/settings.xml 配置本地仓库
(2)在IDEA中配置本地仓库(全局配置)
File - Other Settings - Default Settings ,在弹出窗口中点击左侧菜单如下图所示,设置
MavenHome Directory 和User settings file
创建springboot(根据步骤)
1.file--------new project----------maven------next---------填写GroupId 和ArtifacetId ,点击next按钮(groupid公司名,artifacetld项目名)-----------next--------finish
2.修改pom.xml配置文件
添加
<!--项目名 -->
<name>eternal_parent</name>
<description>永恒项目</description>
<!--springboot父工程依赖(把项目变成springboot项目) -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.1.RELEASE</version>
<relativePath></relativePath>
</parent>
<!--解决post乱码 -->
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.outputEncoding>UTF-8</project.build.outputEncoding>
<java.version>1.8</java.version>
</properties>
<!--添加springboot依赖包-->
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</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-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
</dependencies>
当IDEA右下角弹出提示 ,点击Enable Auto-Import 自动导入依赖
在resources资源包添加application.yml配置文件
server:
port: 9000
spring:
application:
name: eternal #指定服务名
datasource:
driverClassName: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/eternal?characterEncoding=utf-8
username: root
password: 123456
jpa:
database: MySQL
show-sql: true
generate-ddl: true
创建一个启动类(xxxApplication)扫描同包或下级包内容
@SpringBootApplication
public class VideoApplication {
public static void main(String[] args){
SpringApplication.run(VideoApplication.class);
}
}