I have a class that has a MongoDB client member that is introduced through the args constructor:
public class MyDAO { private MongoClient mongoClient; public MyDAO(MongoClient mongoClient) { this.mongoClient = mongoClient;
My bean configuration file bean.xml is as follows:
<bean id="myDao" class="com.example.MyDAO"> <constructor-arg ref="mongo" /> </bean> <bean id="mongo" class="com.mongodb.MongoClient"> <property name="host" value="localhost" /> <property name="port" value=27017 /> </bean>
But I got an error for bean.xml as:
No setter found for property 'port' in class 'com.mongodb.MongoClient'
From MongoDB Javadoc , the MongoClient
class MongoClient
not have setter methods for the host
and port
properties. So how can I embed values ββin this Mongo bean?
tonga source share