English 中文(简体)
剪贴、配置工程、源文件夹分离
原标题:Eclipse, configuring project, source folders separation
  • 时间:2012-05-24 11:03:01
  •  标签:
  • java
  • eclipse

有可能是蒂瓦尔问题...

I have 2 directories within a Java projects that represent (lets say) model and a view. These 2 directories are mapped in eclipse as two source folders, both on build path.

查看类可以使用模型类,第二个方向(模型使用视图)不允许使用。

以这种方式配置 Eclispe 是否合理?

Example (in IDE, while coding):
I can use aClass from model in view logic (class can be imported and so on).
I cannot use aClass from view in model logic (java error generated by Eclipse).

提前感谢:)

问题回答

您应该使用默认 Java < a href=" http:// en.wikipedia. org/ wiki/ Java_ package" rel = “ nofollow” > package

为了防止您的模型课程从您的视图包中获取任何东西,您应该确保您在视图包中的所有课程都有 < a href=" http://docs.oracle.com/javase/tuative/java/javaOO/ access control.html" rel=“nofollow” >modacter of protected (或更低)。

为了确保您的观点能够使用您模型包中的类,您应该确保模型包中的所有类(或者至少是您想要访问的类)都有一个modacter of public

如果您计划使用 < code> OSGi < /code > 并为查看和模型创建两个不同的工程, 您就可以实现这一点。 如果某个特定项目的类别将 < code> ViewProject 改为 < code > modelProject , 则无法( imported), 除非 ViewProject 在 < code> Menifest. mf 文件中将包含该类的软件包标记为 < em > export 软件包 < / em >, 而模型工程则标记为 < em > import 软件包

You can do this by splitting to 2 projects: model and view and add dependency between them. I don t think it is possible within one project in Eclipse. But you can write a simple processor via JSR269 to implement this (check imports).





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签