第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

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

隱式的bean發(fā)現(xiàn)機制與自動裝配后報空指針異常不知道錯在哪求請教

隱式的bean發(fā)現(xiàn)機制與自動裝配后報空指針異常不知道錯在哪求請教

循著那道光前行 2018-03-06 11:34:41
package com.immoc.beanAutoWiring;import org.junit.Test;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.context.ApplicationContext;import org.springframework.context.support.ClassPathXmlApplicationContext;import org.springframework.stereotype.Component;@Componentpublic class BeanAnnDemo { @Autowired private BeanAnnotation beanAnnotation; public static void main(String[] args) { //ApplicationContext applicationContext=new ClassPathXmlApplicationContext("applicationContent2.xml"); BeanAnnDemo demo=new BeanAnnDemo(); demo.test(); } public ?void test(){ beanAnnotation.myHashcode(); beanAnnotation.say("this a test"); }}package com.immoc.beanAutoWiring;import org.springframework.context.annotation.Scope;import org.springframework.stereotype.Component;@Scope("prototype")@Componentpublic class BeanAnnotation { public void say(String string){ System.out.println("BeanAnnotation"+string); } public void myHashcode(){ System.out.println("BeanAnnotation"+this.hashCode()); }}<?xml version="1.0" encoding="UTF-8"?><!-- 指定Spring配置文件的DTD信息 --><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="com.immoc.beanAutoWiring" ?/></beans>error:Exception in thread "main" java.lang.NullPointerException at com.immoc.beanAutoWiring.BeanAnnDemo.test(BeanAnnDemo.java:22) at com.immoc.beanAutoWiring.BeanAnnDemo.main(BeanAnnDemo.java:18)
查看完整描述

3 回答

?
楠寶寶_

TA貢獻46條經(jīng)驗 獲得超18個贊

你這種問題臺籠統(tǒng)化,不貼代碼錯誤信息啥的我們不可能幫的了你

http://img1.sycdn.imooc.com//5a9e178b0001133902580258.jpg

http://img1.sycdn.imooc.com//5a9e178b0001c6a003440344.jpg


查看完整回答
2 反對 回復(fù) 2018-03-06
?
carolcoral

TA貢獻41條經(jīng)驗 獲得超9個贊

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?<context:component-scan base-package="com.immoc" ?/>掃描所有同類型的包 ? ? ? ? ? ? ? ? ? ? ? ? ? ? 報錯空指針是沒找到

查看完整回答
反對 回復(fù) 2018-03-07
?
循著那道光前行

TA貢獻3條經(jīng)驗 獲得超0個贊

代碼如上






查看完整回答
反對 回復(fù) 2018-03-06
  • 3 回答
  • 0 關(guān)注
  • 1523 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號