eclipse 在eclipse中为Spring MVC配置构建路径分步教程

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9239482/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 17:42:09  来源:igfitidea点击:

Configure the build path in eclipse for Spring MVC Step-By-Step Tutorial

eclipsespring-mvc

提问by AbdulAziz

I begun this Spring MVC Step-By-Step Tutorial part 1at 1.8 it says

我在 1.8开始了这个Spring MVC 逐步教程第 1 部分,它说

"If you are using an IDE, you will want to configure your project's build path by adding the jars from the 'lib' directory. You will also want to add servlet-api.jar from your servlet container's 'lib' directory ('${appserver.lib}'). Adding these to your build path should successfully resolve all the import statements in the 'HelloController.java' file."

“如果您使用的是 IDE,您将需要通过从 'lib' 目录中添加 jar 来配置项目的构建路径。您还需要从 servlet 容器的 'lib' 目录('$ {appserver.lib}')。将这些添加到您的构建路径应该可以成功解析 'HelloController.java' 文件中的所有导入语句。”

I add jars in the 'lib' folder but the issues does not solves. I could not figure out how to configure the build path. Can any one help. Thanks

我在“lib”文件夹中添加了 jars,但问题没有解决。我不知道如何配置构建路径。任何人都可以帮忙。谢谢

回答by esaj

Right-click on your project root and select Build Path-> Configure Build Path.... Select the Libraries-tab and click Add JARs.... Navigate to your projects' lib-folder and select the .jar -files, then click Ok.

右键单击您的项目根目录并选择Build Path-> Configure Build Path...。选择Libraries-tab 并单击Add JARs...。导航到您的项目的文件lib夹并选择 .jar 文件,然后单击Ok

Edit: From the comment below:

编辑:从下面的评论:

can I define the library once and for every project I just mention the path

我可以为每个项目定义一次库吗?我只提到了路径

If you have multiple projects that use the same jar-archive or archives, you can define a User library for your Eclipse-installation: Select Window-> Preferences, then Java-> Build Path-> User Libraries. Click New, give a name to your user library and click Ok. Select the User library you just added, and click Add JARs..., navigate to the jar you want to add to the library and click Ok. Note that single User library can contain multiple jars (such as all needed Spring-jars, like core, webmvc, tx...), so you can keep repeating the Add JARs...-step.

如果您有多个项目使用相同的 jar-archive 或档案,您可以为 Eclipse 安装定义一个用户库:选择Window-> Preferences,然后Java-> Build Path-> User Libraries。单击New,为您的用户库命名并单击Ok。选择刚刚添加的 User 库,然后单击Add JARs...,导航到要添加到库中的 jar 并单击Ok。请注意,单个用户库可以包含多个 jar(例如所有需要的 Spring-jar,如 core、webmvc、tx...),因此您可以不断重复Add JARs...-step。

When you want to use the defined user library in your project, go to the Libraries-tab in your projects' Build Path, and click Add Library, then select User Libraryand click Next. Now you can pick the library from your user libraries you've defined.

如果要在项目中使用定义的用户库,请转到Libraries项目构建路径中的 - 选项卡,然后单击Add Library,然后选择User Library并单击Next。现在您可以从您定义的用户库中选择库。