Difference between Deployment Assembly and J2EE Module Dependencies in Eclipse

对着背影说爱祢 提交于 2019-11-28 21:40:54
BalusC

I could find on google and understood that it is similar to the J2EE Module dependencies

It was called "J2EE Module Dependencies" until with Eclipse 3.5. After that version, it was renamed to "Deployment Assembly". But it's effectively the same in case of Java EE web projects.


The question is that, why I had to fix the jar in deployment assembly since its a standalone project

Because this way Eclipse will autobuild a JAR file of the project and put in /WEB-INF/lib of the web project's deployment. If you don't do that, the JAR isn't available during webapp's runtime, but only during compiletime and Eclipse expects that you've already built and placed it anywhere else in runtime classpath, e.g. server's own /lib.


if I would not have this deployment assembly , how could this be fixed?

Manually build/export the JAR and drop in webapp's own /WEB-INF/lib or server's own /lib. The "Deployment Assembly" configuration is however more easy and the recommended way.

See also:

When assembling a WAR, Eclipse cannot tell just by looking at your build path dependencies whether they are something that should be bundled in WAR's WEB-INF/lib directory or if they are something that you expect to be available on your server classpath. Extra metadata is needed to differentiate among those cases.

If you look in your problems view, you should see numerous warnings that look like this:

"Classpath entry [something] will not be exported or published..."

Right click on these and select "Quick Fix". You will see a dialog with available fixes. One of them is going to say something like "Mark the associated classpath entry as publish/export dependency...". Use that option.

The above will make a slight alteration to your Java project's .classpath file to tag the dependencies for inclusion in the assembly. You can test without running by exporting a WAR file and checking the contents of WEB-INF/lib folder.

Build path - place your jar's here directly, it will be available for code runtime and compile time.

Deployment assembly - eclipse expects the projects under this path to be bundled and deployed as .jar in web-inf/lib folder. So that it is available for both compile time and run time. If the project is not deployed in deployment assembly then the code is available only for compile time, eclipse won't bundle it and at run-time dependent projects are unavailable to the code.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!