亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

junit 測試 找不到beanname

junit 測試 找不到beanname

Ipython9 2018-05-05 23:13:22
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'studentBean' is defined但是beanname 我已經定義過來; @Test public void student() { ApplicationContext context = new ClassPathXmlApplicationContext( "classpath*:applicationContext.xml"); Student obj = (Student) context.getBean("studentBean"); System.out.print(obj.getName()); }<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"? ? 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.xsd">? ? <bean id="studentBean" class="com.frank.springmvc.controller.Student">? ? ? ? <!-- 在這里寫額外的bean的配置和相關引用 -->? ? ? ? <property name="name" value="hanyu"></property>? ? </bean>? ?? ? <!-- 更多數據訪問層的bean定義寫在這里 --></beans
查看完整描述

1 回答

?
qq_木偶_2

TA貢獻10條經驗 獲得超4個贊

代碼看起來沒問題…會不會是配置文件名字不一致

查看完整回答
反對 回復 2018-05-07
  • 1 回答
  • 1 關注
  • 1393 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號