Java 包与文件夹结构?有什么区别 [英] Java Package Vs Folder-Structure? what is the difference

查看:23
本文介绍了Java 包与文件夹结构?有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道 Eclipse IDE 中用于 Java EE 开发的文件夹结构和包之间有什么区别.

I would like to know What are the difference between folder-structure and package used in Eclipse IDE for Java EE development.

我们什么时候使用哪个,为什么?.

When do we use which one and why?.

应该怎么做

  • 创建一个像src/com/utils这样的文件夹结构,然后在里面创建一个类
  • 创建一个像 src.com.util 这样的包,然后在里面创建一个类

如果我以后必须编写 ant 脚本进行部署,哪个选项会更好且易于部署?

which option would be better and easy to deploy if i have to write a ant script later for deployment ?

如果我采用文件夹结构,部署是否会像将文件从开发复制到部署目标一样简单?

if i go for the folder-structure will the deployment is as easy as copying files from development to deployment target ?

推荐答案

如果你正确配置了东西.在 src 中添加文件夹,与从 File > 中添加包相同.新包.

If you configured stuffs correctly. Adding a folder inside src, is same as adding a package from File > New Package.

因此,这取决于您,无论您感觉如何——添加文件夹或创建包.此外,当您将东西放在 src 下时,包名称从子文件夹开始.所以,src/com/naishe/test 将是包 com.naishe.test.

So, it's up to you, whatever feels comfortable to you -- add a folder or create a package. Also, when you put stuffs under src the package name starts from subfolder. So, src/com/naishe/test will be package com.naishe.test.

这篇关于Java 包与文件夹结构?有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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