您的位置:首页 > 其它

使用GreenDao 报"This check is to prevent accidental file generation into a wrong path."错误

2016-02-26 11:50 1021 查看
参考:/article/9448409.html

最近使用了GreenDao 第三方框架 。Github: https://github.com/greenrobot/greenDAO

结果在Demo练习中碰到了这么一个错误,

This program comes with ABSOLUTELY NO WARRANTY

Exception in thread "main" java.io.IOException: ../DaoExample/src/main/java does not exist. This check is to prevent accidental file generation into a wrong path.

at de.greenrobot.daogenerator.DaoGenerator.toFileForceExists(DaoGenerator.java:128)

at de.greenrobot.daogenerator.DaoGenerator.generateAll(DaoGenerator.java:86)

at de.greenrobot.daogenerator.DaoGenerator.generateAll(DaoGenerator.java:79)

at de.greenrobot.daogenerator.gentest.ExampleDaoGenerator.main(ExampleDaoGenerator.java:39)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:483)

at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)

Process finished with exit code 1



网上答案真的不多,再看了 /article/9448409.html 这篇博客之后,发现如果按照作者的意思来解决,路径是 ././{$ProjectName}/app/src/main/{$PackageName}
,如下图所示:





结果经过测试,发现仍旧会报如下的错误,如下图所示:



熟悉JAVA IO操作的朋友都知道,Windows中路径的表示

然后,我将路径改成这样:

./../{$ProjectName}/app/src/main/java-gen,

然后Run 发现成功了,

再次说明一下:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: