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

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

如何將 applicationContext.xml 轉(zhuǎn)換為 spring

如何將 applicationContext.xml 轉(zhuǎn)換為 spring

UYOU 2024-01-05 16:45:29
我有這個applicationContext.xml文件,我想將其表達為彈簧@Configuration組件。我怎樣才能做到這一點?Spring官方文檔中有關(guān)于如何將XML配置轉(zhuǎn)換為基于Java的配置的部分嗎?以下 XML 片段來自該項目,它為 Spring 實現(xiàn)了自定義 ViewScope。為了使用它的 ViewScope 實現(xiàn),我必須將此配置添加到 my 中applicationContext.xml,但我想用 Java 表達此配置。<bean class="org.springframework.beans.factory.config.CustomScopeConfigurer">    <property name="scopes">        <map>            <entry key="view">                <bean class="com.github.jneat.jsf.ViewScope"/>            </entry>        </map>    </property></bean>
查看完整描述

2 回答

?
守候你守候我

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

您可以嘗試這個(在您指出的項目的自述文件中):

import java.util.HashMap;

import java.util.Map;


import com.github.jneat.jsf.ViewScope;

import org.springframework.beans.factory.config.CustomScopeConfigurer;

import org.springframework.context.annotation.Configuration;


@Configuration

public class MyViewScope {


    @Bean

    public CustomScopeConfigurer customScopeConfigurer() {

        CustomScopeConfigurer configurer = new CustomScopeConfigurer();


        Map<String,Object> scopes = new HashMap<String,Object>();

        scope.put("view", new ViewScope());


        configurer.setScopes(scopes);

        return configurer;

    }

}

你也可以看看這個問題


查看完整回答
反對 回復(fù) 2024-01-05
?
ibeautiful

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

嘗試這個:


@Bean

public CustomScopeConfigurer customScope(WorkflowScope viewScope) {

    CustomScopeConfigurer configurer = new CustomScopeConfigurer();

    Map<String, Object> viewScope = new HashMap<>();


    viewScopeSet.put("view", viewScope);

    configurer.setScopes(viewScopeSet);


    return configurer;

}


查看完整回答
反對 回復(fù) 2024-01-05
  • 2 回答
  • 0 關(guān)注
  • 214 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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