NutzCN Logo
问答 希望调用DataSourceCompositeResolver(final DataSourceResolver[] dataSourceResolvers)构造器,mail.json怎么配置?
发布于 2571天前 作者 zaozaool 1539 次浏览 复制 上一个帖子 下一个帖子
标签:
public DataSourceCompositeResolver(final DataSourceResolver[] dataSourceResolvers)
    {
        this.dataSourceResolvers = new DataSourceResolver[dataSourceResolvers.length];
        System.arraycopy(dataSourceResolvers, 0, this.dataSourceResolvers, 0, dataSourceResolvers.length);
    }

var ioc={
	emailAuthenticator : {
		type : "org.apache.commons.mail.DefaultAuthenticator",
		args : [{java:"$conf.get('mail.UserName')"}, {java:"$conf.get('mail.Password')"}]
	},
	dataSourceClassPathResolver : {
		type : "org.apache.commons.mail.resolver.DataSourceClassPathResolver"
	},
	dataSourceFileResolver : {
		type : "org.apache.commons.mail.resolver.DataSourceFileResolver"
	},
	dataSourceUrlResolver : {
		type : "org.apache.commons.mail.resolver.DataSourceUrlResolver",
		args : "http://"
	},
    dataSourceCompositeResolver : {
		type : "org.apache.commons.mail.resolver.DataSourceCompositeResolver",
		args : [{refer: "dataSourceClassPathResolver"}, {refer: "dataSourceFileResolver"}, {refer: "dataSourceUrlResolver"}]
	},
	htmlEmail : {
		type : "com.bsc.app.web.commons.services.email.ImageHtmlEmail",
		singleton : false,
		fields : {
			hostName : {java:"$conf.get('mail.HostName')"},
			smtpPort : {java:"$conf.get('mail.SmtpPort')"},
			authenticator : {refer:"emailAuthenticator"},
			SSLOnConnect : {java:"$conf.get('mail.SSLOnConnect')"},
			from : {java:"$conf.get('mail.From')"},
			smtpSocketFactoryFallback : {java:"$conf.get('mail.SmtpSocketFactoryFallback')"},
			smtpStartTlsEnable : {java:"$conf.get('mail.SmtpStartTlsEnable')"},
			debug : {java:"$conf.get('mail.debug')"},
			dataSourceResolver : {refer: "dataSourceCompositeResolver"}
		}
	}	
};
3 回复

试试这样写

    dataSourceCompositeResolver : {
		type : "org.apache.commons.mail.resolver.DataSourceCompositeResolver",
		args : [{refer: "dataSourceClassPathResolver"},[{refer: "dataSourceFileResolver"}, {refer: "dataSourceUrlResolver"}]]
	},

或者用java代码的方式

@IocBean
public class MailBeans {
       @Inject("refer:$ioc")
       Ioc ioc;
       
       @IocBean
        public DataSourceCompositeResolver () {
                return new DataSourceCompositeResolver(new DataSourceClassPathResolver(), new ......); // 如果需要其他bean,可以从ioc容器取
        }
}

应该这样写,java方式我没试

 dataSourceCompositeResolver : {
		type : "org.apache.commons.mail.resolver.DataSourceCompositeResolver",
		args : [[{refer: "dataSourceClassPathResolver"}, {refer: "dataSourceFileResolver"}, {refer: "dataSourceUrlResolver"}]]
	},

哦哦,整个是个数组

添加回复
请先登陆
回到顶部