是否有 Eclipse 部署程序集丢失 Maven 依赖项的永久修复程序?
Is there a permanent fix for Eclipse Deployment Assembly losing the Maven Dependencies?
我遇到了与此类似的问题 (java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener),不同之处在于常见的修复(将 Maven 依赖项添加到 Deployment Assembly)只是暂时的,每次我执行 Maven 时它都会中断更新,虽然不是太频繁,但也够烦人了。
是否有永久性修复?
详情
这是我得到的错误
然后我到这里修复它:
然后这里:
终于到了...
这是修复后的样子:
这是我的 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>ctc.web.proyect</groupId>
<artifactId>front.web</artifactId>
<packaging>war</packaging>
<version>0.2.5</version>
<name>front.web</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<javax.servlet.version>3.1.0</javax.servlet.version>
<javax.servlet.jstl>1.2</javax.servlet.jstl>
<org.springframework.version>4.1.5.RELEASE</org.springframework.version>
<thymeleaf.version>2.1.4.RELEASE</thymeleaf.version>
<jackson.version>2.5.3</jackson.version>
<mysql.version>5.1.30</mysql.version>
<c3p0.version>0.9.1.2</c3p0.version>
<logback.version>1.1.1</logback.version>
<slf4j.version>1.7.7</slf4j.version>
<testng.version>6.8.8</testng.version>
<commons-lang3.version>3.3.2</commons-lang3.version>
<mockito.version>1.9.5</mockito.version>
<cglib.version>2.2.2</cglib.version>
<guava.version>18.0</guava.version>
<commons-collections.version>3.2.1</commons-collections.version>
<commons-validator.version>1.4.1</commons-validator.version>
<javax.mail.version>1.4.7</javax.mail.version>
<org.aspectj.version>1.8.6</org.aspectj.version>
<apache.lucene.version>5.3.0</apache.lucene.version>
</properties>
<dependencies>
<!-- JAVAX SERVLET LIB DEPENDENCY -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>${javax.servlet.jstl}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>${javax.servlet.version}</version>
</dependency>
<!--
SPRING DEPENDENCIES
-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${org.springframework.version}</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring4</artifactId>
<version>${thymeleaf.version}</version>
</dependency>
<!--
JDBC Data Access Library (depends on spring-core, spring-beans, spring-context, spring-tx)
Define this if you use Spring's JdbcTemplate API (org.springframework.jdbc.*)
-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${org.springframework.version}</version>
<scope>test</scope>
</dependency>
<!-- JACKSON LIB DEPENDENCY FOR JSON SER/DES -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<!-- MYSQL DB LIB -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
</dependency>
<!-- LogBack dependencies -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>c3p0</groupId>
<artifactId>c3p0</artifactId>
<version>${c3p0.version}</version>
</dependency>
<!-- COMMONS LIB DEPENDCY -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>${commons-collections.version}</version>
</dependency>
<dependency>
<groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId>
<version>${commons-validator.version}</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- GUAVA. We still use it in java 8 for immutable collections -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${guava.version}</version>
</dependency>
<!-- TESTING DEPENDENCY -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>${testng.version}</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>${mockito.version}</version>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>${cglib.version}</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>${javax.mail.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${org.aspectj.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${org.aspectj.version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-core</artifactId>
<version>${apache.lucene.version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-analyzers-common</artifactId>
<version>${apache.lucene.version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-queries</artifactId>
<version>${apache.lucene.version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-queryparser</artifactId>
<version>${apache.lucene.version}</version>
</dependency>
<!-- <dependency> -->
<!-- <groupId>org.compass-project</groupId> -->
<!-- <artifactId>compass</artifactId> -->
<!-- <version>2.2.0</version> -->
<!-- </dependency> -->
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId>
<version>1.20.0</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<finalName>ROOT</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<inherited>true</inherited>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
每当我进行 Maven 更新时,我都需要手动重复所有步骤来修复 Web 部署程序集。我实际上已经遇到这个问题几个月了。如有任何建议,我们将不胜感激。
您的 Pom.xml
似乎还不错。但是,如果您右键单击您的项目,在 "maven" 到 "enable dependency management" 下应该有一个选项。而已。
PS:如果您使用的是 m2eclipse,请避免使用 maven-eclipse-plugin
。完全没有必要,它会令人困惑,它会产生一些混乱。除非你真的知道自己在做什么,否则不要使用它。
希望这对您有所帮助。
此类问题解决方法:
- 正在获取 Eclipse IDE for Java EE Developers 的最新版本。截至今天,这是 Eclipse Mars 4.5。请务必 select 64 位版本(如果您的计算机是 64 位)并安装最新的 64 位 JDK(截至今天,这是 jdk-8u60)。
- 通过 select 在首选项 ("Java > Installed JREs") 中安装 JDK,在 Eclipse 中正确设置 JRE。
- 拥有最新的
m2e
和 m2e-wtp
插件。这是通过转到 "Help > Install New Software...",为 m2e-wtp
设置 this URL for m2e
and this URL,然后安装每个建议的软件(之后不要忘记重新启动 Eclipse)来完成的。
- 在 Eclipse 中正确设置服务器:在 "Servers" 视图中,右键单击并 select "New > Server" 然后按照您的特定服务器的步骤操作;最后,您需要通过 "Add and Remove..." 屏幕添加您的
war
。
- 通过 select 清理 Eclipse 中的项目并转到 "Project > Clean"。
- 通过在 Eclipse 中右键单击项目并转到 "Maven > Update Project..." 来更新 Maven 项目。
- 通过右键单击服务器并 selecting "Clean" 来清理服务器(这取决于您的服务器,但通常有一个 "Clean" 选项)。
我建议您在全新安装 Eclipse 时执行所有这些步骤,以避免一般缓存问题。
附带说明一下,您的 POM 按原样存在几个问题:
javax.servlet:javax.servlet-api
依赖项需要具有 provided
范围,因为此依赖项始终由 Web 服务器在 运行 时提供。
javax.servlet:jstl
依赖项可能不需要 compile
范围,runtime
就足够了。
- 您在不需要时声明了很多 Spring 依赖项:它们仍将包含在内,因为它们已经是其他工件的传递依赖项。因此,您可以删除
spring-aop
、spring-beans
、spring-context
、spring-expression
、spring-tx
和 spring-web
. 的声明
- 您的测试依赖项缺少
test
范围(testng
、mockito-all
...)
<inherited>true</inherited>
在你的 maven-compiler-plugin
声明中是不必要的,因为这是 the default.
最终 POM 将是:
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ctc.web.proyect</groupId>
<artifactId>front.web</artifactId>
<packaging>war</packaging>
<version>0.2.5</version>
<name>front.web</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<javax.servlet.version>3.1.0</javax.servlet.version>
<javax.servlet.jstl>1.2</javax.servlet.jstl>
<org.springframework.version>4.1.5.RELEASE</org.springframework.version>
<thymeleaf.version>2.1.4.RELEASE</thymeleaf.version>
<jackson.version>2.5.3</jackson.version>
<mysql.version>5.1.30</mysql.version>
<c3p0.version>0.9.1.2</c3p0.version>
<logback.version>1.1.1</logback.version>
<slf4j.version>1.7.7</slf4j.version>
<testng.version>6.8.8</testng.version>
<commons-lang3.version>3.3.2</commons-lang3.version>
<mockito.version>1.9.5</mockito.version>
<cglib.version>2.2.2</cglib.version>
<guava.version>18.0</guava.version>
<commons-validator.version>1.4.1</commons-validator.version>
<javax.mail.version>1.4.7</javax.mail.version>
<org.aspectj.version>1.8.6</org.aspectj.version>
<apache.lucene.version>5.3.0</apache.lucene.version>
</properties>
<dependencies>
<!-- JAVAX SERVLET LIB DEPENDENCY -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>${javax.servlet.jstl}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>${javax.servlet.version}</version>
<scope>provided</scope>
</dependency>
<!-- SPRING DEPENDENCIES -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${org.springframework.version}</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring4</artifactId>
<version>${thymeleaf.version}</version>
</dependency>
<!-- JDBC Data Access Library (depends on spring-core, spring-beans, spring-context,
spring-tx) Define this if you use Spring's JdbcTemplate API (org.springframework.jdbc.*) -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${org.springframework.version}</version>
<scope>test</scope>
</dependency>
<!-- JACKSON LIB DEPENDENCY FOR JSON SER/DES -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<!-- MYSQL DB LIB -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
</dependency>
<!-- LogBack dependencies -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>c3p0</groupId>
<artifactId>c3p0</artifactId>
<version>${c3p0.version}</version>
</dependency>
<!-- COMMONS LIB DEPENDCY -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version>
</dependency>
<dependency>
<groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId>
<version>${commons-validator.version}</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- GUAVA. We still use it in java 8 for immutable collections -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${guava.version}</version>
</dependency>
<!-- TESTING DEPENDENCY -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>${testng.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>${cglib.version}</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>${javax.mail.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${org.aspectj.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${org.aspectj.version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-analyzers-common</artifactId>
<version>${apache.lucene.version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-queryparser</artifactId>
<version>${apache.lucene.version}</version>
</dependency>
<!-- <dependency> -->
<!-- <groupId>org.compass-project</groupId> -->
<!-- <artifactId>compass</artifactId> -->
<!-- <version>2.2.0</version> -->
<!-- </dependency> -->
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId>
<version>1.20.0</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<finalName>ROOT</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
您可能想要解决的另一个问题是您的 groupId
和 artifactId
不遵循 Maven 约定:更喜欢使用 -
作为分隔符而不是 .
。
要遵循的清单很长 - 对于没有安装 m2e 和 m2e-wtp 的我来说,"cleaning the project in Eclipse by selecting it and going to "项目 > 清理“。”使用默认配置文件运行 Maven 构建。
因为我遇到了类似的问题,解决方案是在 pom.xml
.
中将包装更改为“war”
<packaging>war</packaging>
我遇到了与此类似的问题 (java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener),不同之处在于常见的修复(将 Maven 依赖项添加到 Deployment Assembly)只是暂时的,每次我执行 Maven 时它都会中断更新,虽然不是太频繁,但也够烦人了。
是否有永久性修复?
详情
这是我得到的错误
然后我到这里修复它:
然后这里:
终于到了...
这是修复后的样子:
这是我的 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>ctc.web.proyect</groupId>
<artifactId>front.web</artifactId>
<packaging>war</packaging>
<version>0.2.5</version>
<name>front.web</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<javax.servlet.version>3.1.0</javax.servlet.version>
<javax.servlet.jstl>1.2</javax.servlet.jstl>
<org.springframework.version>4.1.5.RELEASE</org.springframework.version>
<thymeleaf.version>2.1.4.RELEASE</thymeleaf.version>
<jackson.version>2.5.3</jackson.version>
<mysql.version>5.1.30</mysql.version>
<c3p0.version>0.9.1.2</c3p0.version>
<logback.version>1.1.1</logback.version>
<slf4j.version>1.7.7</slf4j.version>
<testng.version>6.8.8</testng.version>
<commons-lang3.version>3.3.2</commons-lang3.version>
<mockito.version>1.9.5</mockito.version>
<cglib.version>2.2.2</cglib.version>
<guava.version>18.0</guava.version>
<commons-collections.version>3.2.1</commons-collections.version>
<commons-validator.version>1.4.1</commons-validator.version>
<javax.mail.version>1.4.7</javax.mail.version>
<org.aspectj.version>1.8.6</org.aspectj.version>
<apache.lucene.version>5.3.0</apache.lucene.version>
</properties>
<dependencies>
<!-- JAVAX SERVLET LIB DEPENDENCY -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>${javax.servlet.jstl}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>${javax.servlet.version}</version>
</dependency>
<!--
SPRING DEPENDENCIES
-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${org.springframework.version}</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring4</artifactId>
<version>${thymeleaf.version}</version>
</dependency>
<!--
JDBC Data Access Library (depends on spring-core, spring-beans, spring-context, spring-tx)
Define this if you use Spring's JdbcTemplate API (org.springframework.jdbc.*)
-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${org.springframework.version}</version>
<scope>test</scope>
</dependency>
<!-- JACKSON LIB DEPENDENCY FOR JSON SER/DES -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<!-- MYSQL DB LIB -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
</dependency>
<!-- LogBack dependencies -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>c3p0</groupId>
<artifactId>c3p0</artifactId>
<version>${c3p0.version}</version>
</dependency>
<!-- COMMONS LIB DEPENDCY -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>${commons-collections.version}</version>
</dependency>
<dependency>
<groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId>
<version>${commons-validator.version}</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- GUAVA. We still use it in java 8 for immutable collections -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${guava.version}</version>
</dependency>
<!-- TESTING DEPENDENCY -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>${testng.version}</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>${mockito.version}</version>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>${cglib.version}</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>${javax.mail.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${org.aspectj.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${org.aspectj.version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-core</artifactId>
<version>${apache.lucene.version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-analyzers-common</artifactId>
<version>${apache.lucene.version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-queries</artifactId>
<version>${apache.lucene.version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-queryparser</artifactId>
<version>${apache.lucene.version}</version>
</dependency>
<!-- <dependency> -->
<!-- <groupId>org.compass-project</groupId> -->
<!-- <artifactId>compass</artifactId> -->
<!-- <version>2.2.0</version> -->
<!-- </dependency> -->
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId>
<version>1.20.0</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<finalName>ROOT</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<inherited>true</inherited>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
每当我进行 Maven 更新时,我都需要手动重复所有步骤来修复 Web 部署程序集。我实际上已经遇到这个问题几个月了。如有任何建议,我们将不胜感激。
您的 Pom.xml
似乎还不错。但是,如果您右键单击您的项目,在 "maven" 到 "enable dependency management" 下应该有一个选项。而已。
PS:如果您使用的是 m2eclipse,请避免使用 maven-eclipse-plugin
。完全没有必要,它会令人困惑,它会产生一些混乱。除非你真的知道自己在做什么,否则不要使用它。
希望这对您有所帮助。
此类问题解决方法:
- 正在获取 Eclipse IDE for Java EE Developers 的最新版本。截至今天,这是 Eclipse Mars 4.5。请务必 select 64 位版本(如果您的计算机是 64 位)并安装最新的 64 位 JDK(截至今天,这是 jdk-8u60)。
- 通过 select 在首选项 ("Java > Installed JREs") 中安装 JDK,在 Eclipse 中正确设置 JRE。
- 拥有最新的
m2e
和m2e-wtp
插件。这是通过转到 "Help > Install New Software...",为m2e-wtp
设置 this URL form2e
and this URL,然后安装每个建议的软件(之后不要忘记重新启动 Eclipse)来完成的。 - 在 Eclipse 中正确设置服务器:在 "Servers" 视图中,右键单击并 select "New > Server" 然后按照您的特定服务器的步骤操作;最后,您需要通过 "Add and Remove..." 屏幕添加您的
war
。 - 通过 select 清理 Eclipse 中的项目并转到 "Project > Clean"。
- 通过在 Eclipse 中右键单击项目并转到 "Maven > Update Project..." 来更新 Maven 项目。
- 通过右键单击服务器并 selecting "Clean" 来清理服务器(这取决于您的服务器,但通常有一个 "Clean" 选项)。
我建议您在全新安装 Eclipse 时执行所有这些步骤,以避免一般缓存问题。
附带说明一下,您的 POM 按原样存在几个问题:
javax.servlet:javax.servlet-api
依赖项需要具有provided
范围,因为此依赖项始终由 Web 服务器在 运行 时提供。javax.servlet:jstl
依赖项可能不需要compile
范围,runtime
就足够了。- 您在不需要时声明了很多 Spring 依赖项:它们仍将包含在内,因为它们已经是其他工件的传递依赖项。因此,您可以删除
spring-aop
、spring-beans
、spring-context
、spring-expression
、spring-tx
和spring-web
. 的声明
- 您的测试依赖项缺少
test
范围(testng
、mockito-all
...) <inherited>true</inherited>
在你的maven-compiler-plugin
声明中是不必要的,因为这是 the default.
最终 POM 将是:
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ctc.web.proyect</groupId>
<artifactId>front.web</artifactId>
<packaging>war</packaging>
<version>0.2.5</version>
<name>front.web</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<javax.servlet.version>3.1.0</javax.servlet.version>
<javax.servlet.jstl>1.2</javax.servlet.jstl>
<org.springframework.version>4.1.5.RELEASE</org.springframework.version>
<thymeleaf.version>2.1.4.RELEASE</thymeleaf.version>
<jackson.version>2.5.3</jackson.version>
<mysql.version>5.1.30</mysql.version>
<c3p0.version>0.9.1.2</c3p0.version>
<logback.version>1.1.1</logback.version>
<slf4j.version>1.7.7</slf4j.version>
<testng.version>6.8.8</testng.version>
<commons-lang3.version>3.3.2</commons-lang3.version>
<mockito.version>1.9.5</mockito.version>
<cglib.version>2.2.2</cglib.version>
<guava.version>18.0</guava.version>
<commons-validator.version>1.4.1</commons-validator.version>
<javax.mail.version>1.4.7</javax.mail.version>
<org.aspectj.version>1.8.6</org.aspectj.version>
<apache.lucene.version>5.3.0</apache.lucene.version>
</properties>
<dependencies>
<!-- JAVAX SERVLET LIB DEPENDENCY -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>${javax.servlet.jstl}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>${javax.servlet.version}</version>
<scope>provided</scope>
</dependency>
<!-- SPRING DEPENDENCIES -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${org.springframework.version}</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring4</artifactId>
<version>${thymeleaf.version}</version>
</dependency>
<!-- JDBC Data Access Library (depends on spring-core, spring-beans, spring-context,
spring-tx) Define this if you use Spring's JdbcTemplate API (org.springframework.jdbc.*) -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${org.springframework.version}</version>
<scope>test</scope>
</dependency>
<!-- JACKSON LIB DEPENDENCY FOR JSON SER/DES -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<!-- MYSQL DB LIB -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
</dependency>
<!-- LogBack dependencies -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>c3p0</groupId>
<artifactId>c3p0</artifactId>
<version>${c3p0.version}</version>
</dependency>
<!-- COMMONS LIB DEPENDCY -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version>
</dependency>
<dependency>
<groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId>
<version>${commons-validator.version}</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- GUAVA. We still use it in java 8 for immutable collections -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${guava.version}</version>
</dependency>
<!-- TESTING DEPENDENCY -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>${testng.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>${cglib.version}</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>${javax.mail.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${org.aspectj.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${org.aspectj.version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-analyzers-common</artifactId>
<version>${apache.lucene.version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-queryparser</artifactId>
<version>${apache.lucene.version}</version>
</dependency>
<!-- <dependency> -->
<!-- <groupId>org.compass-project</groupId> -->
<!-- <artifactId>compass</artifactId> -->
<!-- <version>2.2.0</version> -->
<!-- </dependency> -->
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId>
<version>1.20.0</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<finalName>ROOT</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
您可能想要解决的另一个问题是您的 groupId
和 artifactId
不遵循 Maven 约定:更喜欢使用 -
作为分隔符而不是 .
。
要遵循的清单很长 - 对于没有安装 m2e 和 m2e-wtp 的我来说,"cleaning the project in Eclipse by selecting it and going to "项目 > 清理“。”使用默认配置文件运行 Maven 构建。
因为我遇到了类似的问题,解决方案是在 pom.xml
.
<packaging>war</packaging>