Spring 2.0,使用<aop:config>来配置AOP<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd"><beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/
schema/beans
http://www.springframework.org/schema/beans/
spring-beans-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/
spring-aop-2.0.xsd">
</beans>
红色字体部分无法同时存在
报错:Attribute "xmlns" must be declared for element type "beans".如果删掉这个:<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
就会报错:cvc-elt.1: Cannot find the declaration of element 'beans'.
因为我用的是spring 2.0但如果删掉<beans>中的那些,我就无法在<beans>里使用<aop:config>这些元素来配置怎么解决啊
能否贴上你们用的配置文件啊谢谢
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd"><beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/
schema/beans
http://www.springframework.org/schema/beans/
spring-beans-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/
spring-aop-2.0.xsd">
</beans>
红色字体部分无法同时存在
报错:Attribute "xmlns" must be declared for element type "beans".如果删掉这个:<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
就会报错:cvc-elt.1: Cannot find the declaration of element 'beans'.
因为我用的是spring 2.0但如果删掉<beans>中的那些,我就无法在<beans>里使用<aop:config>这些元素来配置怎么解决啊
能否贴上你们用的配置文件啊谢谢
解决方案 »
- 发现java在命令行下面.clss文件不能直接运行的原因了
- 急,在线等!调用ajax,返回json,报异常java.lang.OutOfMemoryError: Java heap space
- 求帮助xml解析,各位大侠帮帮忙
- 请问一下hibernate中怎么保存字段的默认值
- 望JSF高手指点
- 关于bean的问题
- 无法在Sun Java™ System Application Server Platform Edition 8.1上部署spring+hibernate+struts的应用程序
- 请问在struts中调用action时出现一下错误是怎末办?在线等
- jndi中properties.put(Context.SECURITY_PRINCIPAL, user)的user 指的是什么的用户
- SpringBoot 怎么再拦截器里面注入Service
- 保存数据到数据库出现的奇怪问题
- struts2 如何过滤敏感字符?
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation" value="classpath:hibernate.cfg.xml"></property>
</bean></beans>
我要Spring2.0以上的
而且还可以用<aop:config>等元素来配置AOP的
不过我是初学者,还没用到<aop:confin>
我上面那个就是我写的项目中的,没有异常
用了之后就不可以了
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<aop:config>
<aop:advisor pointcut="execution(* ssh.service.*.*(..))"
advice-ref="txAdvice" />
</aop:config></beans>能用 spring2.5
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
">
</beans>
最好的方法是: 根据下载的spring 导入对应的jar包 然后配置xml文件的时候,从其例子里面拷贝其配置信息,就可以了!比如我引入的jar包 是2.5.6 我直接从下载的jpetstore例子中抽取配置文件头信息就可以了
下面的配置信息:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
需引入spring.jar 2.5.6版本