【发布时间】:2016-06-04 18:18:07
【问题描述】:
我正在开发一个 Java 项目。我正在使用 Maven 来处理依赖项。我在 pom.xml 文件中添加了几个依赖项,但是当我运行启动 TomCat 服务器的 index.html 文件(在项目中)时,生成的 TARGET 文件夹不包含任何依赖项 JAR 文件.
这是我第一次使用 Maven。我一直在寻找这个问题一两个小时,但我似乎找不到答案。我读过插件,但我不明白它们是如何工作的。
我正在使用带有 Maven 插件的 IntelliJ IDEA。 我在项目中有依赖项,在外部库下,由 Maven 处理。
我希望依赖 JAR 文件位于目标 > 项目名 > WEB-INF> 库中。
Pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>demoblog</groupId>
<artifactId>demoblog</artifactId>
<packaging>war</packaging>
<version>1.0</version>
<name>demoblog</name>
<repositories>
<repository>
<id>eap</id>
<url>http://maven.repository.redhat.com/techpreview/all</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>eap</id>
<url>http://maven.repository.redhat.com/techpreview/all</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.2-1003-jdbc4</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.25</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>2.22.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
<version>1.0.4</version>
</dependency>
</dependencies>
<profiles>
<profile>
<!-- When built in OpenShift the 'openshift' profile will be used when
invoking mvn. -->
<!-- Use this profile for any OpenShift specific customization your app
will need. -->
<!-- By default that is to put the resulting archive into the 'webapps'
folder. -->
<!-- http://maven.apache.org/guides/mini/guide-building-for-different-environments.html -->
<id>openshift</id>
<build>
<finalName>demoblog</finalName>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<outputDirectory>webapps</outputDirectory>
<warName>ROOT</warName>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
【问题讨论】:
-
同时添加有问题的 pom.xml。
-
@HimanshuBhardwaj 已添加,谢谢您告诉我。
-
@HimanshuBhardwaj 我删除了泽西依赖项下“提供”的行,并修复了它!不知道它是如何到达那里的。谢谢。
标签: java maven tomcat intellij-idea