【Maven】Eclipse项目红色感叹号,JAR包无报错

疑惑了很久,我那个上说什么jar包导错,配置文件错,看了一下都是对的,但是就是红色感叹号,代码无法导入包

 

解决方案:

查看problems( window--》show view--》problems),找到报错显示目录(我的是/home/hadoop/.m2/repository/)

进入maven配置时设置的.m2目录,找到你导入失败的那个目录,发现是之前配置时多导入了几个版本,简单粗暴,直接删除目录  rm -rf ../hive-exec/

然后确认配置文件pom.xml无误,右键项目→maven→update projects

记得勾选Force update of Snapshots/Releases

OK

再查看目录,重新导入完毕,红感叹号消失,完美解决

【Maven】Eclipse项目红色感叹号,JAR包无报错_第1张图片

[hadoop@cdaisuke ~]$ ls -a
.              .gconfd          .nautilus
..             .gnome2          Pictures
.abrt          .gnome2_private  Public
.bash_history  .gnote           .pulse
.bash_logout   .gnupg           .pulse-cookie
.bash_profile  .gstreamer-0.10  .recently-used.xbel
.bashrc        .gtk-bookmarks   .ssh
.cache         .gvfs            Templates
.config        .hivehistory     .thumbnails
.dbus          .ICEauthority    Videos
Desktop        .imsettings.log  .viminfo
.dmrc          .local           workspace
Documents      .m2              .xsession-errors
Downloads      .mozilla         .xsession-errors.old
.esd_auth      Music
.gconf         .mysql_history
[hadoop@cdaisuke ~]$ cd .m2
[hadoop@cdaisuke .m2]$ ls
repository  settings.xml
[hadoop@cdaisuke .m2]$ cd repository/
[hadoop@cdaisuke repository]$ cd org/apache/hive/
[hadoop@cdaisuke hive]$ ls
hive      hive-common  hive-jdbc       hive-serde    hive-shims
hive-ant  hive-exec    hive-metastore  hive-service  shims
[hadoop@cdaisuke hive]$ cd hive-exec/0.13.1/
[hadoop@cdaisuke 0.13.1]$ ls
hive-exec-0.13.1.jar  hive-exec-0.13.1.pom.sha1
hive-exec-0.13.1.pom  _maven.repositories
[hadoop@cdaisuke 0.13.1]$ cd ../
[hadoop@cdaisuke hive-exec]$ ls
0.13.1  0.13.1-cdh5.3.3  0.13.2  0.14.0
[hadoop@cdaisuke hive-exec]$ rm -rf ../hive-exec/
[hadoop@cdaisuke hive-exec]$ cd ../
[hadoop@cdaisuke hive]$ cd hive-exec/
[hadoop@cdaisuke hive-exec]$ ls
0.13.1

 

你可能感兴趣的:(解决方案)