首先开头说几点:这次更新拖了很久:主要原因我没时间又遇到各种问题,和我自己也是刚接触这一种开发也是在尝试一步步走起来
1.遇到错误:下载慢
<!-- 阿里云搭建了一个国内镜像http://maven.aliyun.com,跑起来速度很快,可以进行配置-->
<repositories>
<repository>
<id>nexus-aliyun</id>
<name>nexus-aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
2.有个地方爆红(我以前是选择2.2.5)(后面实在不行我就换了 (2.1.7.RELEASE)这个版本)
3.这个不算错误吧(这回导致下载不下线上的包)
4.删除这个东西应为一般是在这个项目下包下载不下来(这个我们作为新手先跳过学习)
1.首先是配置一个连接msql 库
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
2.现在运行肯定报错的
配置以上信息,这是springboot 简化的操作,所以配置上面这几个基本可以简单做到连接数据库
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
#设置样式也就是数据库连接诶方式:主要看你用了啥数据库
spring.datasource.url=jdbc:mysql://192.168.0.1:3306/yang?charset=utf8mb4&useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC
#配置 192.168.0.1:3306/yang = (地址(本地/线上 ip)):端口 /这是数据库名称
spring.datasource.username=yang
#登录名称
spring.datasource.password=yangdepeng
#登录密码
3准备交互数据这块
先添加依赖(使用 jpa 框架)
<!-- 数据交互配置 jpa-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>RELEASE</version>
<scope>compile</scope>
</dependency>
application.properties 添加以下配置
## jpa
spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.show-sql=false
#spring.jpa.hibernate.ddl-auto=create
基本以上就配置完成所需的内容了,
下一章 :第四章(获取数据打印)