Java InvalidPropertyException:无效属性';classDAO';bean类的:无属性';classDAO';
嗨,我一直在尝试在我们的服务器上实现一个新的bean。每次我尝试运行服务器时,它都会抛出此错误 org.springframework.beans.factory.BeanCreationException:创建名为“walletToWalletService”的bean时出错[文件:/opt/WSappl/webapps/axis2/WEB-INF/springjdbc.xml]:初始化 豆荚失败;嵌套异常为org.springframework.beans.InvalidPropertyException:bean类[com.cbas.jdbc.walletToWallet.WalletToWalletServiceImpl]的无效属性“walletToWalletDAO”: 未找到属性“walletToWalletDAO” 下面是springjdbc.xml文件Java InvalidPropertyException:无效属性';classDAO';bean类的:无属性';classDAO';,java,spring,Java,Spring,嗨,我一直在尝试在我们的服务器上实现一个新的bean。每次我尝试运行服务器时,它都会抛出此错误 org.springframework.beans.factory.BeanCreationException:创建名为“walletToWalletService”的bean时出错[文件:/opt/WSappl/webapps/axis2/WEB-INF/springjdbc.xml]:初始化 豆荚失败;嵌套异常为org.springframework.beans.InvalidPropertyEx
<bean id="walletToWalletDAO" class="com.cbas.jdbc.walletToWallet.WalletToWalletDAO">
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>
<bean id="walletToWalletService" class="com.cbas.jdbc.walletToWallet.WalletToWalletServiceImpl">
<property name="walletToWalletDAO">
<ref bean="walletToWalletDAO" />
</property>
</bean>
您是否声明了变量private WalletToWalletDao WalletToWalletDao;在WalletToWalletServiceImpl中?错误抱怨WalletToWalletServiceImpl中缺少属性。该类的代码在哪里?是否使用基于注释的配置?然后你必须用
@Repository
注释并在spring配置文件中添加
来注释你的DAO
类。这很尴尬。我只是把walletToWalletDao的房产和walletToWalletDao错卖了。我很抱歉。谢谢@Kalyan的提示。@Deus Levin谢谢你对拼写错误的评论!!!这让我找到了一个setter方法,该方法在重构过程中没有被重命名,这给我带来了类似的问题。
package com.cbas.jdbc.walletToWallet;
import com.cbas.jdbc.common.BaseDAO;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource;
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
import org.springframework.jdbc.core.simple.SimpleJdbcInsert;
public class WalletToWalletDAO extends BaseDAO
{
private static String TABLE = "WALLET_EVENT_LOG";
public static String FIELD_ID = "ID";
public static String FIELD_MSISDN = "MSISDN";
public static String FIELD_AMOUNT = "AMOUNT";
public static String FIELD_DEST_ACCOUNT = "DEST_ACCOUNT";
public static String FIELD_TRANSFER_DATE = "TRANSFER_DATE";
public static String FIELD_CHANNEL_TYPE = "CHANNEL_TYPE";
protected String getTable()
{
return this.TABLE;
}
protected RowMapper getObjectMapper()
{
return new WalletToWalletRowMapper();
}
protected long save(WalletToWalletBean record) {
SqlParameterSource parameters = new BeanPropertySqlParameterSource(record);
SimpleJdbcInsert simpleJdbcInsert = getSimpleJdbcInsert().withTableName(getTable()).usingGeneratedKeyColumns(new String[] { "ID" });
return simpleJdbcInsert.executeAndReturnKey(parameters).longValue();
}
protected void delete(long id) {
StringBuilder builder = new StringBuilder("DELETE FROM ");
builder.append(getTable());
builder.append(" WHERE ");
builder.append(FIELD_ID).append("=");
builder.append(id);
getJdbcTemplate().execute(builder.toString());
}
}