我试图在PluralSight上学习this教程来学习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");
上面的代码行说不能解析ApplicationContext
和ClassPathXmlApplicationContext
。
我试图找出这些类是否已经改变,有利于任何其他类,但我没有在Spring网站上找到任何此类信息。
我错过了什么或者在5.0.0之后使用Spring的方式有什么变化
我们pom.khml:
<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>
请从这里获取所有依赖项: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