记录回家第一天的bug解决和心理过程

1、先说正事

背景:Mac下干净的环境,配置实验室工程所需开发环境,遇到了一系列的问题

工程是用Springboot+maven+vue组成的,使用的IDE是IDEA

问题1:在IDEA 下右边框里的Maven---reimport maven all projects后告诉我无法import ,log日志如下

ERROR -      #org.jetbrains.idea.maven - com.google.inject.CreationException: Unable to create injector, see the following errors:

1) No implementation for org.apache.maven.model.path.PathTranslator was bound.
  while locating org.apache.maven.model.path.PathTranslator
    for field at org.apache.maven.model.interpolation.AbstractStringBasedModelInterpolator.pathTranslator(Unknown Source)
  at org.codehaus.plexus.DefaultPlexusContainer$1.configure(DefaultPlexusContainer.java:350)

2) No implementation for org.apache.maven.model.path.UrlNormalizer was bound.
  while locating org.apache.maven.model.path.UrlNormalizer
    for field at org.apache.maven.model.interpolation.AbstractStringBasedModelInterpolator.urlNormalizer(Unknown Source)
  at org.codehaus.plexus.DefaultPlexusContainer$1.configure(DefaultPlexusContainer.java:350)

2 errors 

这个问题 

我根据这个一句

No implementation for org.apache.maven.model.path.PathTranslator was bound.

百度看了一圈,最相近的是这一篇?在这 关于ideal2019版本配置maven问题  https://ask.csdn.net/questions/789238

我独立安装的是maven3.6.2 下面评论区大佬告诉我,3.6.2版本不稳定,建议回退版本,看到好几个大佬是这样说的,因此,我选择尝试方法,一顿操作猛如虎(上面的问题已经让我非常熟练的卸装配置path,更改IDEA里的配置),但是官网下载有点慢,外国服务器的通病,快速的更换了版本,主要操作如下

1、下载maven旧版本,开始找了半天,也有可能是英语不好,看不懂,因此看的是这篇 Maven历史版本下载  https://blog.csdn.net/STIll_ly/article/details/80905149

2、还是放在usr/local/底下和我的3.6.2放在一起,然后更改path,配置环境变量方法如下

在终端打开配置环境变量到文件:
1)在终端输入  vim ~/.bash_profile,进入到环境变量配置文件里面;
2)进入后,是read模式,按下 i (编辑)键,进入insert模式;
3)将环境变量加入其实,环境变量如下:
export MAVEN_HOME=/usr/local/apache-maven-3.5.4
export PATH=$PATH:$MAVEN_HOME/bin
4)按下 ESC,退出insert模式;
5)输入 :wq (保存修改)退出当前文件;
6)使修改的环境变量bash_profile文件生效,输入 source .bash_profile,按下Enter键即可.
7)检验环境变量是否改成功,重新打开终端 mvn -v,显示版本号

3、 修改maven配置文件,改conf/setting.xml文件,添加maven阿里云镜像,这个你们可以去搜,网上大多正确

注意注意:错误的地方来了:有些配置maven的博文,让改maven的仓库repository地址,我就改了,导致我IDEA配置maven-local repository的时候,修改使用本地maven和本地仓库,结果,IDEA还是找不到我导在本地仓库的jar文件,改了使用本地仓库地址也没同步,我醉了,然后,下一次我就聪明了,都默认,没事改什么仓库地址配置。

--总结:maven配置文件只需要添加镜像,听我的,别改仓库地址,配置IDEA的maven时,改上面两行就行,local repository使用默认的,这个在本地maven settings里也有注释告诉你,默认的就是这个地址

然后,再maven-reimport 就不报错了 ,告诉我们一个道理,退几个版本是安全的。

 

问题2:安装本地maven,配置IDEA使用本地的maven和仓库,但是里面的工程依然访问不到里面的jar,缺了特别多的包

解决方法:安装本地maven,maven不要修改仓库地址---配置IDEAmaven项,只配置前两行,仓库也不要修改,如下图

问题3:运行maven工程,报错如下

java: -source 1.6 中不支持 diamond 运算符 (请使用 -source 7 或更高版本以启用)
-source 1.7 中不支持 lambda 表达式(请使用 -source 8 或更高版本以启用 lambda 表达式)

当时,其实有好几行报错,我按照上面一行搜索,结果告诉我,是因为IDEA和maven用的jdk不是一个版本的,我按照,以下链接检查,并没有用。按照第2行搜索,出来靠谱解决方法https://blog.csdn.net/qwdafedv/article/details/54691740

同时参考:https://blog.csdn.net/w893932747/article/details/90518725

首先检查版本,大概有好多方面,有2个比较全的文章(仅供参考)

https://blog.csdn.net/weixin_40649505/article/details/80229794

https://blog.csdn.net/binbinczsohu/article/details/86540416

其次,检查setting文件,发现默认的jdk使用1.4,把它改成1.8,添加内容如下

<profile>  
    <id>jdk18</id>  
    <activation>  
        <activeByDefault>true</activeByDefault>  
        <jdk>1.8</jdk>  
    </activation>  
    <properties>  
        <maven.compiler.source>1.8</maven.compiler.source>  
        <maven.compiler.target>1.8</maven.compiler.target>  
        <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>  
    </properties>   
</profile>

总结--不要只揪着一个错误不放,多搜搜其他的错误,没准就有靠谱解决方法了,现在网上内容真假难辨,慎重啊大家!!

问题4:mac下pgsql+pgadmin的安装坎坷之路

开始先下载了解压版,然后发现找不到配置的地方(后来发现,其实解压版很好用,但我不喜欢装一堆独立的软件的感觉,喜欢用集成器帮你装)

Mac最好的安装pgsql的方法是使用brew install postgresql

然后他会自动帮你下载到brew文件下,同时拷贝一份到usr/local/var/postgresql,这个就不需要初始化了,然后建立用户,数据库。这就可以了。需要远程连接,可以设置远程连接,网上教程一抓一大把。

pgadmin的安装踩了些坑,首先下载了最新版本的pgadmin4,然后发现mac打不开,然后我又去下载了pgadmin3,发现打得开,但是明显感觉到非常不适配,然后我又下载了pgadmin4.1.6和4.3.6,4.1.6报错,4.3.6正常,就是我想要的那个web版可视化界面,然后新建服务器-数据库-连接localhost:5432本地pg数据库,导入备份,完美~忍不住吐槽一下,这个软件对mac太不友好了吧

问题5:vue工程使用npm install构建工程,报错

MacBook:modeler-web root$ npm install
npm WARN tarball tarball data for [email protected] (sha512-FLOXyzoMCXY+8Y3klkbH4lMz/hfy/sRHXBv9xPfgVZ04o0Kxp9t3+TqFl6SlNhu/QVJmBKh5caHcnktZCPOGLw==) seems to be corrupted. Trying one more time.
npm WARN tarball tarball data for [email protected] (sha512-FLOXyzoMCXY+8Y3klkbH4lMz/hfy/sRHXBv9xPfgVZ04o0Kxp9t3+TqFl6SlNhu/QVJmBKh5caHcnktZCPOGLw==) seems to be corrupted. Trying one more time.
npm WARN tar ENOENT: no such file or directory, open '/Users/root/file/DWF3.0/modeler-web/node_modules/.staging/core-util-is-732ae849/test.js'
npm WARN tar ENOENT: no such file or directory, open '/Users/root/file/DWF3.0/modeler-web/node_modules/.staging/eslint-config-prettier-ada45224/LICENSE'
npm WARN tar ENOENT: no such file or directory, open '/Users/root/file/DWF3.0/modeler-web/node_modules/.staging/core-util-is-732ae849/float.patch'
npm WARN tar ENOENT: no such file or directory, open '/Users/root/file/DWF3.0/modeler-web/node_modules/.staging/vue-grid-layout-f38d8a15/test/interact-test.html'
npm WARN tar ENOENT: no such file or directory, open '/Users/root/file/DWF3.0/modeler-web/node_modules/.staging/eslint-config-prettier-ada45224/react.js'
npm WARN tar ENOENT: no such file or directory, open '/Users/root/file/DWF3.0/modeler-web/node_modules/.staging/vue-grid-layout-f38d8a15/test/interact-test.js'
npm WARN tar ENOENT: no such file or directory, open '/Users/root/file/DWF3.0/modeler-web/node_modules/.staging/eslint-config-prettier-ada45224/README.md'
npm WARN tar ENOENT: no such file or directory, open '/Users/root/file/DWF3.0/modeler-web/node_modules/.staging/vue-grid-layout-f38d8a15/.github/ISSUE_TEMPLATE/bug_report.md'
npm WARN tar ENOENT: no such file or directory, open '/Users/root/file/DWF3.0/modeler-web/node_modules/.staging/ci-info-30cefddf/vendors.json'
npm WARN tar ENOENT: no such file or directory, open '/Users/root/file/DWF3.0/modeler-web/node_modules/.staging/vue-grid-layout-f38d8a15/.github/ISSUE_TEMPLATE/feature_request.md'
npm WARN tar ENOENT: no such file or directory, open '/Users/root/file/DWF3.0/modeler-web/node_modules/.staging/he-a1f5265f/LICENSE-MIT.txt'
npm WARN tar ENOENT: no such file or directory, open '/Users/root/file/DWF3.0/modeler-web/node_modules/.staging/eslint-config-prettier-ada45224/standard.js'
npm WARN tar ENOENT: no such file or directory, open '/Users/root/file/DWF3.0/modeler-web/node_modules/.staging/vue-grid-layout-f38d8a15/src/assets/logo.png'
npm WARN tar ENOENT: no such file or directory, open '/Users/root/file/DWF3.0/modeler-web/node_modules/.staging/he-a1f5265f/README.md'
npm WARN tar ENOENT: no such file or directory, open '/Users/root/file/DWF3.0/modeler-web/node_modules/.staging/vue-grid-layout-f38d8a15/src/components/CustomDragElement.vue'
npm WARN tar ENOENT: no such file or directory, open '/Users/root/file/DWF3.0/modeler-web/node_modules/.staging/vue-grid-layout-f38d8a15/src/components/GridItem.vue'
npm WARN tar ENOENT: no such file or directory, open '/Users/root/file/DWF3.0/modeler-web/node_modules/.staging/codepage-bbfcd7fe/cputils.js'
npm WARN tar ENOENT: no such file or directory, open '/Users/root/file/DWF3.0/modeler-web/node_modules/.staging/prettier-5bc1f342/parser-vue.js'
npm ERR! code EINTEGRITY
npm ERR! Verification failed while extracting [email protected]:
npm ERR! Verification failed while extracting [email protected]:
npm ERR! sha512-FLOXyzoMCXY+8Y3klkbH4lMz/hfy/sRHXBv9xPfgVZ04o0Kxp9t3+TqFl6SlNhu/QVJmBKh5caHcnktZCPOGLw== integrity checksum failed when using sha512: wanted sha512-FLOXyzoMCXY+8Y3klkbH4lMz/hfy/sRHXBv9xPfgVZ04o0Kxp9t3+TqFl6SlNhu/QVJmBKh5caHcnktZCPOGLw== but got sha512-pKiSJmla7aHGKqI/t4nrehfoJgHdmanEbdR6TQU59m0JP1Md6YZtaQNUq7mRLspd6+1WULOLOQDraU5nF90j0Q==. (942694 bytes)

表面上是 [email protected] 版本问题,我就按照网上很多教程说的回退npm版本,但是结果并没有什么用,搞了至少好几天,又放了一段时间。

解决方法:原因可能是,我安装了cnpm的原因,不能混用,改成cnpm install就成功了,我其实也惊了,就这么简单哎除了程序员,谁每天时在解决一个一个未知的错误中度过的

2、自己给自己叨叨

昨天半天也是这样,遇到好多bug就会这样,感觉人生失去了心念,我怎么这么菜,一天天啥也干不了,当处理完的时候就贼有成就感,自己好厉害啊,还是有厉害之处的哈哈哈哈

最近刚换了电脑,感觉macOS系统确实和用了5年的windows不同,更纯净,像Linux-centos一类的,干净得会让我有一种错觉,舍不得改一些东西,怕改坏了,毁掉了这个美丽的系统

我觉得做事,就要一步到位,不要反反复复做一件事情,浪费时间和精力和耐心

以后记得保留下来自己的解决方法,这样子遇到相同问题,不会觉得“啊,好熟悉,我之前怎么解决的呢”,脑子不好就记下来。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章