Java Web Project referencing another Java project

后端 未结 5 1035
故里飘歌
故里飘歌 2020-12-13 22:37

I have a Java Project, for which I\'m now creating a Web interface, using a Dynamic Web Project from Eclipse. The Web project consists of a single

5条回答
  •  既然无缘
    2020-12-13 23:02

    Consider moving up to EAR level, if your web container supports that.

    The tricky part with shared code is where should the common code be put. A copy pr web application? A copy in the web container? Overdoing the "share these classes" might end up in class loader problems.

    If you are creating two separate web applications refactor common java code into a separate Eclipse project and refer to it from both WAR projects.


    EDIT: Apparently I have misread the problem description, and thought you asked about an existing and a new web application sharing code.

    If you have an Eclipse project with your application, and another with your web frontend, then you can let your application export the necessary resources which the "Export WAR" in Eclipse Java EE can wrap up in a jar file and put in WEB-INF/lib for you. You need to say this explicitly with a checkmark in Properties -> Java EE Module Dependencies for your web project. Expect you have to experiment a bit - this took me a while to learn.

提交回复
热议问题