idea 使用spring maven的过程

idea 使用spring maven的过程

前言

文章参考多人的博客,已注明

一、新建项目

1.新建项目,spring initializr next
image.png

2.设置名称等 next
image.png

3.选择工具
image.png

image.png

4.名称,存储位置
image.png

finish 完成新建

二、错误

1.Error:java: 错误: 不支持发行版本 5
image.png
此处改成自己电脑上的java的版本即可

2.Error:(3, 32) java: 程序包org.springframework.boot不存在
image.png
解决方案:
image.png

3.运行后,加载依赖包;
image.png
比较缓慢
采用阿里云的镜像来完成:
步骤一:overide打勾
image.png
步骤二:在上图的这个路径下的settings.xml文件中加入一下内容(这个文件可能不存在,则新建):

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                          https://maven.apache.org/xsd/settings-1.0.0.xsd">

      <mirrors>
        <mirror>  
            <id>alimaven</id>  
            <name>aliyun maven</name>  
            <url>http://maven.aliyun.com/nexus/content/groups/public/</url>  
            <mirrorOf>central</mirrorOf>          
        </mirror>  
      </mirrors>
</settings>

步骤三:重新打开idea,再次运行即可;
但是我在这种情况下仍然不行,报类似如下错误
Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:2.2.4.RELEASE from/to alimaven (https://maven.aliyun.com/repository/central): PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
解决方案:
1.在画圈处加入如下代码:应用并保存

-Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true

2.打开右侧的maven,点击clean,然后再次尝试运行程序即可;
image.png
(原博客的方式是:clean, complier, install)
原博客:https://blog.csdn.net/xxaann/article/details/104794669

三、项目配置

1.改为.yml文件(可以不改,只要语法正确)

image.png

2.test部分运行时出现如下错误:

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project demo: There are test failures.
Please refer to E:\study-tool\IdeaProjects\demo\target\surefire-reports for the individual test results.
Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.

1.查看标红目录下的错误信息,

image.png
如果自己的数据库是mysql8.0,则错误原因是时区问题:
将java中的url,将时区修改为UTC

url: jdbc:mysql://localhost:3306/ycs?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=true

原博客:https://blog.csdn.net/starlemon2016/article/details/90314649

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值