出现问题和排错

二、出现问题

 

2.1、没有下载maven包

2.1.1、可以在apache官网(https://maven.apache.org/)下载maven;

image-20200727093454135

image-20200727093532001

2.1.2、可以在D盘中新建一个文件夹,存放mave文件和在这个文件夹中新建mvnrep仓库,用来存放项目的各种jar包

image-20200727093628231

2.1.3、然后点击File中的Settings

image-20200727093834992

2.1.4、设置好Maven

image-20200727094044460

2.1.5、设置好Improting,里面的VM Options问题看2.2.2

image-20200727094157739

2.1.6、设置好Runer,里面的VM Options问题看2.2.2

image-20200727094246288

2.1.7、点击第二行第一个东东,进入页面后排查SDK版本是否是1.8的

image-20200727094458524

image-20200727094417490

 

 

 

 

2.2、导包导不了

2.2.1、配置好的下载源

打开apache-maven-3.6.3/conf/settings.xml

 <?xml version="1.0" encoding="UTF-8"?>
 
 <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 http://maven.apache.org/xsd/settings-1.0.0.xsd">
     
     <!--
     配置本地MAVEN仓库位置,默认在:C:\Users\机器名\.m2\repository
     ** Eclipse->Windows->Preferences->java->Build Path->Classpath Variables
     -->
     <localRepository>D:\ideaIU\Environment\mvnrep\</localRepository>  
     
     <pluginGroups>
     </pluginGroups>
 
     <proxies>
     </proxies>
 
     <servers>
     </servers>
 
     <mirrors>
         <!-- 阿里镜像仓库 -->
         <mirror>
             <id>aliyunmaven</id>
             <mirrorOf>*</mirrorOf>
             <name>aliyunmaven</name>
             <url>http://maven.aliyun.com/repository/public</url>
         </mirror>
     </mirrors>
     
     <profiles>
     </profiles>
     
     <activeProfiles>
     </activeProfiles>
 </settings>
 

mirror

 <!-- 阿里镜像仓库 -->
 <mirror>
     <id>aliyunmaven</id>
     <mirrorOf>*</mirrorOf>
     <name>aliyunmaven</name>
     <url>http://maven.aliyun.com/repository/public</url>
 </mirror>

mirror中的url

 <url>http://maven.aliyun.com/repository/public</url>

 

2.2.2、实在不行

实在不行可以在mirror中的url(http://maven.aliyun.com/repository/public)中的(http)改为(https);

如:

 <url>https://maven.aliyun.com/repository/public</url>

 

然后在idea中的File中的settings中的Importing和Runer配置VM Options信息:

image-20200727095506905

image-20200727095524077

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

 

 

三、排查错误

当我们运行项目出错的时候

第一步,先检查jar包是否缺少;

第二步,查看bean注入是否成功(ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml"););

第三步,Junit单元测试,看我们的代码是否能够查询出结果;

第四步,第一,二,三步都没错,那么就是关联失败,spring调用失败;

第五步,SpringMVC,整合的时候没有调用到我们的servvice层的bean

  1. applicationContext.xml没有注入bean;

  2. Web.xml中,我们也绑定过配置文件!发现问题,我们配置的是springmvc-servlet.xml,这里面确实没有service层的bean,所以报空指针;

posted @ 2020-08-08 14:57  沉默非沉默  阅读(212)  评论(0)    收藏  举报