2016-09-04 31 views
2

我创建了一个基于视频培训教程STS Maven项目,我已经完成所有步骤去准确。STS的Spring bean配置文件不具有弹簧XSD命名空间

按照教程,加入spring bean configuration文件后,我希望在命名空间选项卡,可以选择一些类似的命名空间和mvccontext,但我不知道为什么没有。只需Bean,C,PUtil名称空间。

我做了一些谷歌上搜索和其他人也许提到的,那是因为你没有春天罐子在您的项目,但你可以看到这是一个Maven项目和它的正确下载。

enter image description here

+0

我知道这是一个老话题,但你找到一个解决方案? –

+0

是的,请检查我的回复 – Sergio

回答

0

尝试关闭该项目,并在STS再次打开它。右键单击项目并选择Maven - > update project。这解决了我的问题。

0

您需要进口弹簧库。构成Spring的每个库都添加一个新的xsd模式。 如果你想拥有所有可能的架构加上旁边的POM文件:

<dependencyManagement> 
     <dependencies> 
      <dependency> 
       <groupId>org.springframework</groupId> 
       <artifactId>spring-framework-bom</artifactId> 
       <version>${org.springframework-version}</version> 
       <type>pom</type> 
       <scope>import</scope> 
      </dependency> 
     </dependencies> 
    </dependencyManagement> 

的前XML代码不导入所有Spring库到您的项目。您需要逐个添加您需要的弹簧库。之后,您将看到您可以使用Spring的所有模式。

这是给你一个POM例如:

<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>org.webapp</groupId> 
    <artifactId>SL14-04</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <packaging>war</packaging> 
    <properties> 
     <java.version>1.8</java.version> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
     <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> 

     <org.springframework-version>4.3.10.RELEASE</org.springframework-version> 
     <org.aspectj-version>1.8.10</org.aspectj-version> 
     <org.slf4j-version>1.7.25</org.slf4j-version> 
    </properties> 
    <dependencyManagement> 
     <dependencies> 
      <dependency> 
       <groupId>org.springframework</groupId> 
       <artifactId>spring-framework-bom</artifactId> 
       <version>${org.springframework-version}</version> 
       <type>pom</type> 
       <scope>import</scope> 
      </dependency> 
     </dependencies> 
    </dependencyManagement> 
    <dependencies> 
     <!-- Spring --> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-context</artifactId> 
      <exclusions> 
       <!-- Exclude Commons Logging in favor of SLF4j --> 
       <exclusion> 
        <groupId>commons-logging</groupId> 
        <artifactId>commons-logging</artifactId> 
       </exclusion> 
      </exclusions> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-webmvc</artifactId> 
     </dependency> 

    <dependency> 
     <groupId>javax.servlet</groupId> 
     <artifactId>javax.servlet-api</artifactId> 
     <version>3.1.0</version> 
     <scope>provided</scope> 
    </dependency> 

    </dependencies> 
    <build> 
    <plugins> 
     <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <version>2.5.1</version> 
       <configuration> 
        <source>${java.version}</source> 
        <target>${java.version}</target> 
        <encoding>${project.build.sourceEncoding}</encoding> 
        <compilerArgument>-Xlint:all</compilerArgument> 
        <showWarnings>true</showWarnings> 
        <showDeprecation>true</showDeprecation> 
       </configuration> 
     </plugin> 

     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-war-plugin</artifactId> 
      <version>3.1.0</version> 
      <configuration> 
       <failOnMissingWebXml>false</failOnMissingWebXml> 
      </configuration> 
     </plugin> 

    </plugins> 
    </build> 

</project>