在eclipse中将项目转换为maven项目后,不会导入servlet包 [英] servlet packages not importing after converting project to maven project in eclipse
问题描述
<依赖关系>
<依赖关系>
< groupId> javax.servlet< / groupId>
< artifactId> servlet-api< / artifactId>
< version>(,1.0)< / version>
< / dependency>
< / dependencies>
,我包含一个这样的存储库:
< repositories>
< repository>
< id> maven2-repository.dev.java.net< / id>
< name>用于Maven的Java.net存储库< / name>
< url> http://download.java.net/maven/2/< / url>
< layout>默认< / layout>
< / repository>
< / repositories>
仍然依赖关系尚未解决,我的servlet不工作。为什么我的转换的Maven项目使依赖关系管理更容易?为什么servlet导入工作不是更有效?
您可以通过以下方式将依赖项添加到部署中:
- 右键单击项目> Project Pro
- 单击部署程序集
- 单击添加
- 单击Java构建路径条目
- 单击Maven依赖关系
您可以通过以下方式将依赖项添加到构建路径:
- 右键单击项目>项目属性
- 单击Java构建路径
- 单击库
- 单击添加库
- 选择Maven管理依赖关系
您不应该导入servlet依赖项通过Maven,你应该指向你的服务器运行时。您可以通过以下方式进行配置:
- 右键单击项目>项目属性
- 单击Java构建路径
- 单击库
- 单击添加库
- 选择服务器运行时
- 选择您的服务器。
I have a dynamic web application that I've converted to a maven project in Spring Toolsuite (Eclipse, basically.) The project now has a pom.xml file, but the Java Build Path no longer has the jars I used to use because maven is supposed to handle the dependencies. I put the dependencies in the pom like this:
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>(,1.0]</version>
</dependency>
</dependencies>
and I included a repository like so:
<repositories>
<repository>
<id>maven2-repository.dev.java.net</id>
<name>Java.net Repository for Maven</name>
<url>http://download.java.net/maven/2/</url>
<layout>default</layout>
</repository>
</repositories>
Still, the dependency isn't resolved and my servlets aren't working. Why isn't my converted Maven project making dependency management any easier? Why aren't the servlet imports working, more specifically?
You can add the dependencies to the deployment by:
- Right click the project > Project Properties
- Click Deployment Assembly
- Click Add
- Click Java Build Path Entries
- Click Maven Dependencies
You can add the dependencies to the build path by:
- Right click the project > Project Properties
- Click Java Build Path
- Click Libraries
- Click Add Libraries
- Select Maven Managed Dependencies
You shouldn't be importing the servlet dependencies via Maven though, you should be pointing at your servers runtime. You can configure this by:
- Right click the project > Project Properties
- Click Java Build Path
- Click Libraries
- Click Add Libraries
- Select Server Runtime
- Select your server.
这篇关于在eclipse中将项目转换为maven项目后,不会导入servlet包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!