您的位置:首页 > 理论基础 > 计算机网络

eclipse如何导入okhttp 2.x源码

2017-07-20 23:12 423 查看
最近因为公司某个项目的网络请求出现问题,由于公司某个基础库用了okhttp 2.x版本,而基础库是在okhttp 2.x基础上二次封装。为了确定问题不得不导入okhttp源码。因为okhttp 2.x属于很老的版本,所以只能从github上clone下来再切换到对应版本。导入时因为插件太老出现问题:
Plugin execution not covered by lifecycle configuration: org.codehaus.mojo:templating-maven-plugin:1.0-alpha-3:filter-sources (execution: default, phase: generate-sources)

插件templating-maven-plugin的生命周期覆盖有问题





接下来更新插件就可以了
1. 更新插件
插件官网:
https://mvnrepository.com/artifact/org.codehaus.mojo/templating-maven-plugin

可以看到templating-maven-plugin 1.0-alpha-3是2013年的,现在是2017年下半年了,赶紧更新到最新的1.0.0稳定版
<!-- https://mvnrepository.com/artifact/org.codehaus.mojo/templating-maven-plugin -->
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>templating-maven-plugin</artifactId>
<version>1.0.0</version>
</dependency>

2. 这时候可能会提示找不到Version.java类文件
需要手动添加类到项目里面,打开子项目okhttp的.classpath文件添加Version.java类
<classpathentry kind="src" output="target/classes" path="target/generated-sources/java-templates">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>

3. 最后更新maven

选择项目okhttp鼠标右键 --> 选择maven --> update project

到此,大功告成!
说明:当前okhttp已经开发到3.8.1。http://square.github.io/okhttp/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息