Fórum Configurando Spring #508592

27/01/2015

0

Estou configurando o Spring, e no arquivo servlet-context.xml, esta dando erro :

Referenced file contains errors (http://www.springframework.org/schema/). For more information, right click on the message in
the Problems View and select "Show Details..."

Segue abaixo o meu servlet-context.xml:

<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/
beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/
spring-context-3.2.xsd">

<mvc:annotation-driven />

<context:component-scan base-package="br.com.javamagazine"/>

<bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://ip:porta/database"/>
<property name="username" value="username"/>
<property name="password" value="password"/>
</bean>

<bean id="mySessionFactory" class=
"org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="myDataSource"/>
<property name="packagesToScan">
<array>
<value>br.com.javamagazine</value>
</array>
</property>
<property name="hibernateProperties">
<value>hibernate.dialect=org.hibernate.dialect.MySQLDialect
</value>
</property>
</bean>

<bean id="transactionManager" class=
"org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="mySessionFactory"/>
</bean>

<tx:annotation-driven
transaction-manager="transactionManager"/>
</beans>


Alguem pode me ajudar ?
Evandro Abreu

Evandro Abreu

Responder

Posts

27/01/2015

Ronaldo Lanhellas

Pode ser problema no seu buildPath, mostre o seu "pom.xml" se estiver trabalhando com Maven. Caso contrário cheque a aba "Erros" do eclipse e poste aqui.
Responder

Gostei + 0

27/01/2015

Evandro Abreu

segue abaixo o código
<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>br.com.springdev</groupId>
  <artifactId>SpringDevmedia</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>
  
<properties>
    <spring.version>3.2.3.RELEASE</spring.version>
    <hibernate.version>4.2.2.Final</hibernate.version>
  </properties>
 
  <dependencies>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-webmvc</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-orm</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-core</artifactId>
      <version>${hibernate.version}</version>
    </dependency>
		<!-- Implementação de EntityManager da JPA -->
		<dependency>
			<groupId>org.hibernate</groupId>
			<artifactId>hibernate-entitymanager</artifactId>
			<version>4.2.3.Final</version>
			<scope>compile</scope>
		</dependency>
    
    <dependency>
      <groupId>commons-dbcp</groupId>
      <artifactId>commons-dbcp</artifactId>
      <version>1.4</version>
    </dependency>
    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <version>5.1.25</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.jackson</groupId>
      <artifactId>jackson-mapper-asl</artifactId>
      <version>1.9.2</version>
    </dependency>
 </dependencies>
  
</project>


Description Resource Path Location Type
Referenced file contains errors (http://www.springframework.org/schema/). For more information, right click on the message in the Problems View and select "Show Details..." servlet-context.xml /SpringDevmedia/src/main/webapp/WEB-INF/spring line 1 XML Problem
Responder

Gostei + 0

27/01/2015

Ronaldo Lanhellas

Tenta adicionar a seguinte linha na sua tag "<beans"

http://www.springframework.org/schema/data/jpa
    http://www.springframework.org/schema/data/jpa/spring-jpa-1.2.xsd"
Responder

Gostei + 0

27/01/2015

Ronaldo Lanhellas

Tenta adicionar a seguinte linha na sua tag "<beans"

xmlns:jpa="http://www.springframework.org/schema/data/jpa"
http://www.springframework.org/schema/data/jpa
    http://www.springframework.org/schema/data/jpa/spring-jpa-1.2.xsd"
Responder

Gostei + 0

27/01/2015

Evandro Abreu

Ficou dessa forma, mas ainda nao resolveu :

<beans 
  	xmlns="http://www.springframework.org/schema/beans" 
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  	xmlns:beans="http://www.springframework.org/schema/beans"
  	xmlns:context="http://www.springframework.org/schema/context"
        xmlns:mvc="http://www.springframework.org/schema/mvc"
        xmlns:tx="http://www.springframework.org/schema/tx"
        xmlns:jpa="http://www.springframework.org/schema/data/jpa"
     	xsi:schemaLocation="
          http://www.springframework.org/schema/beans 
    	  http://www.springframework.org/schema/
           beans/spring-beans-3.2.xsd
    	  http://www.springframework.org/schema/tx 
    	  http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
          http://www.springframework.org/schema/mvc
    	  http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
    	  http://www.springframework.org/schema/context 
http://www.springframework.org/schema/data/jpa
    http://www.springframework.org/schema/data/jpa/spring-jpa-1.2.xsd    	  
          http://www.springframework.org/schema/context/
           spring-context-3.2.xsd">

Responder

Gostei + 0

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar