Skip to content
This repository has been archived by the owner on Aug 20, 2019. It is now read-only.

AutoTableBindPlugin在maven单元测试中识别classpath的问题 #24

Open
shadowedge opened this issue Jun 23, 2015 · 1 comment
Open

Comments

@shadowedge
Copy link

您好:
使用AutoTableBindPlugin在maven单元测试时,插件通过PathKit.getRootClassPath()默认识别的classpath是【project_root\target\test-classes\】目录,而这个目录下通常没有项目使用的model文件,因为只是针对测试生成的路径。
由于model文件通常都放置在【project_root\target\classes\】目录下,因此做了一下classpath指定:
String cp = PathKit.getRootClassPath();// target\test-classes
String path = rp.substring(0, cp.lastIndexOf("")).concat("\classes");
atbp.classpath(path);
指定后插件可以扫描到正确的classpath,但出现了另一个问题:获取到的全部class文件都少了一部分内容!即,原本名为foobar.model.demo的class被识别成了“r.model.demo”!
查看了下插件源码,发现open里面依然用了原来的classpath(ClassSearcher的83行):
String open = PathKit.getRootClassPath() + File.separator;
导致自定义的classpath被截断了。
麻烦作者确认下是否为bug?
或者说是classpath设定的使用方法不正确?

@shadowedge
Copy link
Author

一种修改方式如下:
1.将ClassSearcher中的classpath变成静态的
private static String classpath = PathKit.getRootClassPath();
2.将String open = PathKit.getRootClassPath() + File.separator;
修改成: String open = classpath + File.separator;

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant