Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Junit 4.11带有java.io.File的临时文件夹构造函数_Java_Eclipse_Maven_Junit4_Temporary Directory - Fatal编程技术网

Junit 4.11带有java.io.File的临时文件夹构造函数

Junit 4.11带有java.io.File的临时文件夹构造函数,java,eclipse,maven,junit4,temporary-directory,Java,Eclipse,Maven,Junit4,Temporary Directory,我正在努力做到这一点。 它在eclipse中工作正常,但在maven中出现错误 示例代码 File baseFolder=new File("C:\BASE_FOLDER"); temporaryFolder = new TemporaryFolder(baseFolder); //Error in maven [ERROR] symbol : constructor TemporaryFolder(java.io.File) [ERROR] location: class org.jun

我正在努力做到这一点。 它在eclipse中工作正常,但在maven中出现错误

示例代码

File baseFolder=new File("C:\BASE_FOLDER");
temporaryFolder = new TemporaryFolder(baseFolder);


//Error in maven
[ERROR] symbol  : constructor TemporaryFolder(java.io.File)
[ERROR] location: class org.junit.rules.TemporaryFolder
任何链接或提示都会很有帮助。 谢谢

完全错误:

symbol  : constructor TemporaryFolder(java.io.File)
location: class org.junit.rules.TemporaryFolder

        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:108)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:76)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:116)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:361)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:213)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:157)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.CompilationFailureException: Compilation failure

由于
TemporaryFolder
是一个文件夹,因此可以将其与
@Rule
注释一起使用。从:

或者,如果要指定位置:

File baseFolder = new File("C:\BASE_FOLDER");
@Rule
public TemporaryFolder folder = new TemporaryFolder(baseFolder);

看起来您在maven构建中缺少JUnit依赖项。maven的完整错误消息是什么?使用-X参数运行。请查看我的编辑中的完整错误。您在pom.xml中是否具有junit依赖项是的,我有。甚至我在.m2目录中检查了构造函数的TemporaryFolder.class文件,它就在那里。
File baseFolder = new File("C:\BASE_FOLDER");
@Rule
public TemporaryFolder folder = new TemporaryFolder(baseFolder);