Maven报错解决:无法访问org.springframework.web.bind.annotation.RequestMapping

首先,我们找到使用@RequestMapping()的类中去查看导包是否正常。

Maven报错解决:无法访问org.springframework.web.bind.annotation.RequestMapping_第1张图片

        现在这里导包是正常的, 导包正常的话,我们可以去pom.xml文件中去看看有没有spring-web这个jar包的坐标导入

          
        
            org.springframework
            spring-web
            5.3.26
        
    

         若没有这个依赖可以先刷新以下maven,看看是否会自动导入,若没有就手动添加上这个依赖。

        若是添加了这个依赖,还是有这个报错的话就去本地仓库中找到这个jar包和spring-web的jar包

Maven报错解决:无法访问org.springframework.web.bind.annotation.RequestMapping_第2张图片

Maven报错解决:无法访问org.springframework.web.bind.annotation.RequestMapping_第3张图片

        仓库中若是没有这个jar包 ,就去中央仓库(Central Repository:)或者流程仓库(阿里云镜像等私服)去下载,由于中央仓库是全球唯一的仓库,地址是在国外,下载会非常的慢,所以建议在私服或者阿里云镜像等流程仓库中下载。

        若是有这个jar包,可能存在下载这个jar包时没有下载完,导致jar包中有文件资源缺失,建议删除掉重新下载试试看。

补充知识(配置阿里云镜像):

        找到下载的maven中的conf文件夹中的setting.xml配置文件,用记事本打开

Maven报错解决:无法访问org.springframework.web.bind.annotation.RequestMapping_第4张图片

        在记事本中找到 标签,然后加入以下内容:

  
   
      
	alimaven  
	aliyun maven  
	http://maven.aliyun.com/nexus/content/groups/public/
	central          
    

  

        添加完毕后,保存(Ctrl+S)并关闭文件就配置好了

你可能感兴趣的:(JavaWeb系列,maven,java,bug)