java-Spring Tool Suite应用程序上下文xml错误,即使所有bean似乎都可以正常工作
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了java-Spring Tool Suite应用程序上下文xml错误,即使所有bean似乎都可以正常工作,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含5587字,纯文字阅读大概需要8分钟。
内容图文
![java-Spring Tool Suite应用程序上下文xml错误,即使所有bean似乎都可以正常工作](/upload/InfoBanner/zyjiaocheng/679/ffc1b730a9a04f1cb019f96dfb44e6a9.jpg)
我正在Spring应用程序上下文xml之一中配置jpa和jpa存储库.
如果我同时拥有< jpa:repositories base-package =“ ...” />和< context:component-scan base-package =“ ...” />然后Spring Tool Suite在第1行显示错误
引用的文件包含错误(http://www.springframework.org/schema/context/spring-context-4.0.xsd).有关更多信息,请右键单击
问题视图,然后选择“显示详细信息…”
在单击显示详细信息后,我得到以下信息:
The errors below were detected when validating the file "spring-context-4.0.xsd" viathe file "app-config.xml". In most cases these errors can be detected by validating "spring-context-4.0.xsd" directly. However it is possible that errors will only occur when spring-context-4.0.xsd is validated in the context of app-config.xml.
sch-props-correct.2: A schema cannot contain two global components with the same name; this schema contains two occurrences of 'http://www.springframework.org/schema/context,propertyPlaceholder'. line 22
sch-props-correct.2: A schema cannot contain two global components with the same name; this schema contains two occurrences of 'http://www.springframework.org/schema/context,property-placeholder'. line 91
sch-props-correct.2: A schema cannot contain two global components with the same name; this schema contains two occurrences of 'http://www.springframework.org/schema/context,property-override'. line 155
sch-props-correct.2: A schema cannot contain two global components with the same name; this schema contains two occurrences of 'http://www.springframework.org/schema/context,annotation.config'. line 174
sch-props-correct.2: A schema cannot contain two global components with the same name; this schema contains two occurrences of 'http://www.springframework.org/schema/context,component-scan'. line 194
sch-props-correct.2: A schema cannot contain two global components with the same name; this schema contains two occurrences of 'http://www.springframework.org/schema/context,load-time-weaver'. line 315
sch-props-correct.2: A schema cannot contain two global components with the same name; this schema contains two occurrences of 'http://www.springframework.org/schema/context,spring-configured'. line 392
sch-props-correct.2: A schema cannot contain two global components with the same name; this schema contains two occurrences of 'http://www.springframework.org/schema/context,mbean-export'. line 405
sch-props-correct.2: A schema cannot contain two global components with the same name; this schema contains two occurrences of 'http://www.springframework.org/schema/context,mbean-server'. line 458
sch-props-correct.2: A schema cannot contain two global components with the same name; this schema contains two occurrences of 'http://www.springframework.org/schema/context,filterType'. line 488
在< jpa:repositories base-package =“ ...” />旁边有警告说找不到引用的bean’jpaMapppingContext’
运行该应用程序似乎正常工作.我可以连接到数据库并使用JpaRepository接口来从数据库中获取数据,所以我不确定为什么在STS中出现致命错误.我假设由于jpa:repositories和context:component-scan扫描程序包都使用时都存在一些重复/冲突,但是我不确定应该如何解决(我可能将服务拆分为它们自己的配置xml,然后将其导入到应用程序配置中,或将其添加到web.xml中的上下文列表中)
这是完整的app-config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.3.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd">
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"
p:driverClassName="org.h2.Driver"
p:url="jdbc:h2:tcp://localhost/~/test;INIT=CREATE SCHEMA IF NOT EXISTS TEST"
p:username="sa"
p:password="" />
<bean id="jpaVendorAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"
p:showSql="true" />
<util:map id="jpaProperties">
<entry key="hibernate.dialect" value="org.hibernate.dialect.H2Dialect" />
<entry key="hibernate.hbm2ddl.auto" value="update" />
<entry key="hibernate.default_schema" value="test" />
</util:map>
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
p:dataSource-ref="dataSource"
p:packagesToScan="hr.mrplow.test.model"
p:jpaVendorAdapter-ref="jpaVendorAdapter"
p:jpaProperties-ref="jpaProperties" />
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"
p:entityManagerFactory-ref="entityManagerFactory"
p:rollbackOnCommitFailure="true" />
<tx:annotation-driven transaction-manager="transactionManager" />
<jpa:repositories base-package="hr.mrplow.test.DAO" />
<!-- Services -->
<context:component-scan base-package="hr.mrplow.test.service" />
</beans>
这是完整的app-config.xml
解决方法:
这是STS中的一个已知问题:
https://jira.spring.io/browse/DATAJPA-160
尽管此问题声称已解决,但您可以在this forum中看到它仍然弹出.
您应该考虑随案一起在Spring上开张jira机票.
内容总结
以上是互联网集市为您收集整理的java-Spring Tool Suite应用程序上下文xml错误,即使所有bean似乎都可以正常工作全部内容,希望文章能够帮你解决java-Spring Tool Suite应用程序上下文xml错误,即使所有bean似乎都可以正常工作所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。