如何移动“WEB-INF / lib”文件夹到Java动态Web应用程序中的子文件夹? [英] How to move "WEB-INF/lib" folder to a sub folder in a Java Dynamic Web App?

查看:401
本文介绍了如何移动“WEB-INF / lib”文件夹到Java动态Web应用程序中的子文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Eclipse中配置Java Dynamic Web Project,以便WEB-INF / lib文件夹位于子文件夹中?

例如,假设我希望我的lib文件夹位于此处:

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


src / main / webapp / WEB-INF / lib

src/main/webapp/WEB-INF/lib

我的webapp root在这里:

and my webapp root is here:


src / main / webapp /

src/main/webapp/

如何在Eclipse中配置它?我知道我可以添加罐子,但我希望它们能够在我应用程序构建路径的Libraries部分的Web App Libraries部分下进行组织。

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.

我尝试了什么:

我尝试添加网络应用库通过执行以下操作,但它没有检测到我的src / main / webapp / WEB-INF / lib文件夹中的jar:

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:


  • 项目|属性| Java构建路径|图书馆|添加库| Web应用程序库

我还确保我的网络应用程序(src / main / webapp)的根目录在我的来源中Build Path上的文件夹也没有运气:

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:


  • 项目|属性| Java构建路径|来源|构建路径上的源文件夹

我知道它可以完成,因为我有另一个项目已配置并正常工作,但是我不确定如何复制配置。

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.

谢谢!

推荐答案

事实证明,我可以通过将以下文件添加到我的项目中来实现此目的:

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

.settings / org.eclipse.wst.common。组件

 <?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":


  • 文件|新建|动态网络项目

  • 完成上一步,直至到达最后一个名为Web的步骤模块

  • 我可以为应用程序指定内容目录,我使用src / main / webapp /\".

  • 这个生成了一个按我喜欢的方式工作的新项目。然后我在项目文件夹中搜索了src / main / webapp并在这个xml文件中找到了它,我刚刚将其复制到我的项目中,并将所有引用从test1更改为我的项目名称,并且它有效!

  • "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!

注意:
您可能还需要在项目中添加Web App Libraries,详见我的问题。

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

这篇关于如何移动“WEB-INF / lib”文件夹到Java动态Web应用程序中的子文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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