我不知道如何在Mulesoft中使用Java Transformer。我想基本上採取一個字符串,並將其轉換爲URL,但我無法弄清楚如何使用Java方法或任何東西。Mulesoft Java Transformer
我在做什麼錯?我怎樣才能讓我調用我的方法,或者讓我的方法與我想要的值一起使用?
ERRORS:
org.mule.module.launcher.DeploymentInitException: IllegalStateException異常:無法轉換類型的值 [transformers.StringTransformer]所需類型 [org.mule.api.processor .MessageProcessor用於屬性 'messageProcessors [4]':沒有匹配的編輯器或轉換策略 發現
所致:org.mule.api.config.ConfigurationException:錯誤創建 名稱爲'streamMigrateAccountToCustomer'的bean:初始化爲 bean失敗;嵌套異常是 org.springframework.beans.ConversionNotSupportedException:無法將 轉換爲屬性'messageProcessors'的類型爲[java.util.ArrayList]的屬性值爲所需類型 [java.util.List];嵌套異常是 java.lang.IllegalStateException:無法將類型 [transformers.StringTransformer]的值轉換爲所需的類型 [org.mule.api.processor.MessageProcessor]屬性 'messageProcessors [4]':沒有匹配的編輯器或轉換戰略 實測值(org.mule.api.lifecycle.InitialisationException) (org.mule.api.config.ConfigurationException)
StringTransformer
@ContainsTransformerMethods
public class StringTransformer
{
public String website;
public String getWebsite() {
return website;
}
public void setWebsite(String website) {
this.website = website;
}
@Transformer
public String stringToURL(String string) throws MalformedURLException
{
return new java.net.URL(string).toString();
}
}
XML
<custom-transformer class="transformers.StringTransformer" doc:name="Java">
<spring:property name="website" value="#[payload.Website]"/>
</custom-transformer>
輸入到JAVA變壓器
%dw 1.0
%output application/java
---
{
Id: payload.Id,
Name: payload.Name,
Active_CMRR__c: payload.Active_CMRR__c,
BillingStreet: payload.BillingStreet,
BillingCity: payload.BillingCity,
BillingState: payload.BillingState,
BillingPostalCode: payload.BillingPostalCode,
BillingCountry: payload.BillingCountry,
OwnerId: payload.OwnerId,
Website: payload.Website,
Contract_End_Date__c: payload.Contract_End_Date__c,
NS_Account_Number__c: payload.NS_Account_Number__c,
Phone: payload.Phone,
Subscription_Start_Date__c: payload.Subscription_Start_Date__c,
NS_Account_Name__c: payload.NS_Account_Name__c,
type: payload.type,
Owner: {
NS_Account_Manager_Id__c: payload.Owner.NS_Account_Manager_Id__c,
Id: payload.Owner.Id,
type: payload.Owner.type,
Name: payload.Owner.Name
}
}
請解釋*如何*在答案本身做到這一點。 –