1

我试图按照PluralSight 上的本教程来学习 Spring。本教程基于 spring 4.3.2,而我想在 5.0.0 上学习它。我使用 mvn 导入了 spring 依赖项:

<dependencies>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>5.0.0.RELEASE</version>
    </dependency>
  </dependencies>

所有依赖项都很好地导入。我创建applicationContext.xml并配置了 bean。现在我在导入时遇到问题ApplicationContext

ApplicationContext appContext = new ClassPathXmlApplicationContext("applicationContext.xml");

上面的代码行说无法解析ApplicationContextClassPathXmlApplicationContext.

我试图找出这些课程是否已更改为有利于任何其他课程,但我没有在 Spring 网站上找到任何此类信息。

我是否遗漏了什么或者在 5.0.0 之后使用 Spring 的方式是否有任何变化

我的 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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.saurabh</groupId>
  <artifactId>spring</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>Spring</name>
  <description>My first attempt at learning spring from Pluralsight</description>

  <!--  the stuff above this was generated automatically while I wrote all that is below -->
  <dependencies>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>5.0.0.RELEASE</version>
    </dependency>
  </dependencies>

  <build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.7.0</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
    </plugins>
  </build>
</project>
4

1 回答 1

0

请从这里获取所有依赖项: Spring Maven Dependency

看起来您正在使用正确的依赖项:

<!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context</artifactId>
    <version>5.0.0.RELEASE</version>
</dependency>

试着做mvn clean install

于 2019-02-22T19:24:22.917 回答