SQLクエリを読み込むためにproperties.getProperty( "")メソッドを使用しようとしています。しかし、常にnullを返します。私はそれぞれの質疑応答を行ってきましたが、実際に必要なものや、間違っていたものが見つかりませんでした。 次のように私の.xmlの設定ファイルは次のとおりです。properties.getProperty( "queryLocation")はnullを返します
<bean id="baseDao" class="com.ems.BaseDao.BaseDao" abstract="true">
<property name="properties" ref="queryPros"/>
</bean>
<bean id="queryPros" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="ignoreResourceNotFound" value="true"/>
<property name="singleton" value="true"/>
<property name="locations">
<list>
<value>classpath*:/com/ems/mssqlFile/HomeDao.mssql.sql</value>
<value>classpath*:/com/ems/mssqlFile/ListDao.mssql</value>
//both cases problem
</list>
</property>
</bean>
マイダオクラスとしては、以下:
public abstract class BaseDao {
protected Properties properties;
public void setProperties(Properties properties) {
this.properties = properties;
}
}
public class HomeDao extends BaseDao implements IHomeDao {
public List<HomeDto> getListFormTable() throws SQLException {
String query = properties.getProperty("ListDao.getListFormTable");
org.hibernate.Query hQuery = hibernateQuery(query);
List<HomeDto> homeDtoList= hQuery.list();
return homeDtoList;
}
}
あなたはうれしくプロパティを含んでいません。 –
@ M.Deinum、ここに私のプロパティです: 'public abstract class BaseDao { protectedプロパティのプロパティ; public void setProperties(プロパティのプロパティ){ this.properties = properties; } } ' –
私はプロパティファイルの内容を意味します。コメントとして追加しないで、質問を編集してください。 –