1

How can I configure a Java Dynamic Web Project in Eclipse so the WEB-INF/lib folder is located in a sub folder?

For example, say I wanted my "lib" folder to be located here:

src/main/webapp/WEB-INF/lib

and my webapp root is here:

src/main/webapp/

How do I configure this in Eclipse? I know I could just "add the jars", but I'd like them to be organized under my "Web App Libraries" section in the Libraries section of my app's build path.


What I've tried:

I've tried adding "Web App Libraries" by doing the following, but it doesn't detect the jars in my "src/main/webapp/WEB-INF/lib" folder:

  • Project | Properties | Java Build Path | Libraries | Add Library | Web App Libraries

I've also ensured that the root of my web app (src/main/webapp) is in my "Source folders on Build Path" as well, with no luck:

  • Project | Properties | Java Build Path | Source | Source folders on Build Path

I know it can be done, as I've got another project that has this configured and working, but I'm not sure how to duplicate the configuration.

Thanks!

4

1 回答 1

1

Turns out that I could get this to work by adding the following file to my project:

.settings/org.eclipse.wst.common.component

 <?xml version="1.0" encoding="UTF-8"?>
  <project-modules id="moduleCoreId" project-version="1.5.0">
      <wb-module deploy-name="test1">
          <wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
          <property name="context-root" value="test1"/>
          <property name="java-output-path" value="/test1/build/classes"/>
      </wb-module>
  </project-modules>

I found this out by creating a brand new "Dynamic Web Project":

  • "File | New | Dynamic Web Project"
  • Go through the steps until you get to the last one called "Web Module"
  • There I could specify a "Content Directory" for the app, and I used "src/main/webapp/".
  • This generated a new project that worked as I liked. I then searched the project folder for "src/main/webapp" and found it in this xml file, which I just copied into my project, and changed all references from "test1" to my projects name, and it worked!

Note: You may also need to add "Web App Libraries" to your project as detailed in my question.

于 2013-01-25T14:10:32.387 回答