简体   繁体   English

新的Java项目结构需要帮助

[英]New Java project structure Help needed

I am not so aware of the java project structure. 我不太了解Java项目结构。 I have few selenium tests which I want to write in java. 我要用Java编写一些硒测试。 So I have chosen eclipse as my editor. 因此,我选择了eclipse作为我的编辑器。 Here I wan to create a new java project with proper folder structure as I am planning to add few more java classes in future. 我打算在这里创建一个具有正确文件夹结构的新Java项目,因为我计划将来再添加几个Java类。

Please let me know how to create an idea java project in eclipse. 请让我知道如何在eclipse中创建一个想法java项目。 I have seen people create something like com.org.project_name etc and then src , resources directories inside that. 我见过人们创建诸如com.org.project_name之类的东西,然后创建其中的资源目录src。

I am not able to make any sense out of those. 我无法从中获得任何意义。 Please explain. 请解释。

The software project management tool Apache Maven recommends, uses and expects a common directory layout that can be considered as best practise . 软件项目管理工具Apache Maven建议,使用并期望可以被视为最佳实践的通用目录布局。

An overview can be found here: Introduction to the Standard Directory Layout 可以在此处找到概述: 标准目录布局简介

Eclipse应该为您创建合适的文件夹...这里有一个示例http://www.wikihow.com/Create-a-New-Java-Project-in-Eclipse

If you want to have a Java Project then go to File -> New -> Java Project. 如果要使用Java项目,请转到“文件”->“新建”->“ Java项目”。

If its web application then, select Dynamic Web Project. 如果是其Web应用程序,则选择“动态Web项目”。

These will automatically create the required structures. 这些将自动创建所需的结构。

在此处输入图片说明

In Java you work in packages, which define the scope of your classes, and is basically the only thing you should really be concentrating on in the beginning. 在Java中,您使用包来定义类的范围,而包基本上是一开始真正要专注的事情。 There's a good article on the subject here - http://docs.oracle.com/javase/tutorial/java/package/packages.html 这里有一篇关于该主题的好文章-http://docs.oracle.com/javase/tutorial/java/package/packages.html

In Java you can create packages. 在Java中,您可以创建包。 Simply said packages are folders that contain classes. 简而言之,软件包是包含类的文件夹。

The statement import java.net.Socket means: from the folder java/net import the class named Socket . 语句import java.net.Socket意思是:从java/net文件夹中导入名为Socket的类。

The statement package myApplication.util.SuperCounter means that the class SuperCounter can be found under myApplication/util folder. 声明package myApplication.util.SuperCounter意味着该类SuperCounter下可以找到myApplication/util文件夹中。

Packages are an easy way to organize your work. 打包是组织工作的简便方法。 Because in a big project you will have class name collisions (ie classes that use the same name). 因为在一个大项目中,您将遇到类名冲突(即使用相同名称的类)。 With packages you can avoid it. 使用软件包可以避免这种情况。

Also Java supports default (private, public, protected). Java也支持默认值(私有,公共,受保护)。 Default methods, attributes, classes can only be seen by elements in the same package! 默认方法,属性,类只能由同一包中的元素看到!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM