源文件夹不在Java构建类路径上,使用JUnit [英] source folder is not on the java build class path, using JUnit

查看:343
本文介绍了源文件夹不在Java构建类路径上,使用JUnit的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Web开发的新手,我已经下载了一些演示项目来学习如何使用Eclipse开发REST客户端应用程序。

I am new to web development and I've downloaded some demo projects to learn how to develop REST client side application using Eclipse.

这是两个例子:

我正在尝试使用JUnit为项目1编写一些测试用例,但是,右键单击(一个类)=>新的Junit测试用例=>错误一直发生,告诉我源文件夹不在java上构建类路径我无法创建JUnit文件。

I am trying to write some test cases using JUnit for project 1, however, Right Click (a class) => new Junit Test Case => the error happens all the time telling me "source folder is not on the java build class path" and I can not create the JUnit file.

但是对于项目2,所有信息都会自动填充。

But for the project 2, all the info is filled automatically.

如果我右键单击src第二次项目和构建路径从构建路径中删除,它将成为与proj 1相同的格式(文件夹)。但是有关包名称和所有导入语句的数百个源代码错误。

If I right click src for second project and in build path "remove from build path", it will become the same format (folders) as proj 1. But hundreds of errors of source code about package name, and all the "import" statements.

它与Eclipse的工作方式有关吗?任何人都可以简单解释一下如何将proj 1更改为正确的格式吗?我试图为proj 1构建路径并且......数百个源代码错误..

Is it related to how Eclipse works? Could anyone give a simple explanation of how I can change the proj 1 to the correct format? I tried to "build path" for proj 1 and... hundreds of error of the source code..

谢谢!

推荐答案

在项目属性中(右键单击项目文件夹并从菜单中选择属性)转到Java Build Path并添加 src 作为源文件夹。

In the project properties (right click on the project folder and select "Properties" from the menu) go to "Java Build Path" and add src as source folder.

这篇关于源文件夹不在Java构建类路径上,使用JUnit的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆