PropertyUtils.setSimplePropertyを使用してセッターメソッドを動的に呼び出そうとしていますが、エラーが発生します。根本原因を突き止めるためにあなたの助けが必要です。ここに私のコードは次のとおりです。java.lang.NoSuchMethodException::java.lang.NoSuchMethodExceptionの取得:PropertyUtils.setSimpleProperty関数を使用しているときにクラス 'class xx'にプロパティ 'xx'が設定されていません
class FileDt {
String reportName=null;
String reportLocation=null;
public String getReportName() {
return reportName;
}
public void setReportName(String reportName) {
this.reportName = reportName;
}
public String getReportLocation() {
return reportLocation;
}
public void setReportLocation(String reportLocation) {
this.reportLocation = reportLocation;
}
}
class Foo {
public static void main (String... args) {
FileDt dt = newFileDt();
// #1
PropertyUtilsBean.setSimpleProperty(dt, "reportName", "abc.html");
// #2
PropertyUtilsBean.setSimpleProperty(dt, "reportLocation", "c://");
}
}
どちらの方法でも例外によって引き起こさ
-
を投げるプロパティ 'REPORTNAME' は、クラスのクラスFileDtにはsetterメソッドを持っていません「 でorg.apache.commons.beanutils.PropertyUtilsBean.setSimpleProperty(PropertyUtilsBean.java:2096)
-
に起因
でクラスのクラスFileDt 'にはセッターメソッドを持っていません:java.lang.NoSuchMethodException:プロパティ 'reportLocation' はorg.apache.commons.beanutils.PropertyUtilsBean.setSimpleProperty(PropertyUtilsBean.java:2096)
は私が提供してきました答えをしましたあなたの問題を解決する? –