IntelliJ - 包org.springframework.stereotype不存在

时间:2017-11-14 12:38:27

标签: java spring maven intellij-idea

我刚刚开始使用IntelliJ并致力于打造一个非常简单的'#34; hello world"应用。它看起来像一个非常简单的设置问题,但我无法找到有效的解决方案。

这是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.jay.jayWorld</groupId>
  <artifactId>simple-project</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>simple-project</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-webmvc</artifactId>
      <version>${springframework.version}</version>
    </dependency>
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>javax.servlet-api</artifactId>
      <version>3.1.0</version>
    </dependency>
    <dependency>
      <groupId>javax.servlet.jsp</groupId>
      <artifactId>javax.servlet.jsp-api</artifactId>
      <version>2.3.1</version>
    </dependency>
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>jstl</artifactId>
      <version>1.2</version>
    </dependency>
  </dependencies>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.2</version>
          <configuration>
            <source>1.6</source>
            <target>1.6</target>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
    <finalName>Spring4MVCHelloWorldDemo</finalName>
  </build>
</project>

是因为我使用$ {springframework.version}吗?我从一些项目中看到这种方法有效,但在我的项目中并非如此。我需要在某处定义吗?

这是错误的屏幕截图。 enter image description here

1 个答案:

答案 0 :(得分:2)

您需要在maven POM中定义名为springframework.version的属性。喜欢这个

<properties>
    <springframework.version>4.3.11</springframework.version>
</properties>