在寫beanAnnotation時(shí)的問(wèn)題
<?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: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.xsd" >
? ? ? ??
? ? ? ? <context:component-scan base-package="main.java.beanAnnotation"></context:component-scan>
? ? ? ??
?</beans>
package main.java.beanAnnotation;
import org.springframework.stereotype.Component;
@Component
public class BeanAnnotation {
public void say(String word){
System.out.println("Annotation"+word+this.hashCode());
}
}
import test.ioc.base.UnitTestBase;
public class TestBeanAnnotation extends UnitTestBase{
public TestBeanAnnotation(){
super("classpath:Spring-beanscope.xml");
}
@Test
public void testAnnotation(){
BeanAnnotation test=super.getBean("beanAnnotation");
test.say("第一個(gè)bean啊");
}
}
代碼如上,報(bào)錯(cuò):Unexpected exception parsing XML document from class path resource [Spring-beanscope.xml];?
求解答
2022-03-24
lt;a?href="javascript:void(0);"gt;lt;/agt;這樣也可以。#可以用于完成top的回到頂部操作,而void(0)是指空操作是因為w3c里不允許p嵌套放塊狀元素嗎?
2018-05-13
super.getBean("beanAnnotation")前要加強(qiáng)制類型轉(zhuǎn)換,應(yīng)該這樣寫:(BeanAnnotation)super.getBean("beanAnnotation")