Код: Выделить всё
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'graphiteWriterSession' defined in file [/home/user/resources/jmxtrans.graphite.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'host' of bean class [com.example.ExampleClass]: Bean property 'host' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
Код: Выделить всё
Код: Выделить всё
package com.example.ExampleClass;
import com.googlecode.jmxtrans.model.output.GraphiteWriter;
public class ExampleClass {
private static final long serialVersionUID = 1L;
private String host;
private int port;
private GraphiteWriter gw;
public ExampleClass() {
}
public GraphiteWriter getWriter() {
gw = new GraphiteWriter();
gw.addSetting(GraphiteWriter.PORT, port);
gw.addSetting(GraphiteWriter.HOST, host);
return gw;
}
// =====================================================
// set/get methods for Carbon host.
// Plugged into Spring application-context file.
// =====================================================
public void setCarbonHost( String host ) {
this.host = host;
}
public String getCarbonHost() {
return host;
}
// =====================================================
// =====================================================
// set/get methods for Carbon port.
// Plugged into Spring application-context file.
// =====================================================
public void setCarbonPort( int port ) {
this.port = port;
}
public int getCarbonPort() {
return port;
}
// =====================================================
}
В приведенной выше ошибке показан «хост», Свойство имеет проблему, но, как и следовало ожидать, свойство «порт» имеет ту же проблему (так уж получилось, что сначала оценивается свойство «хост»).
Может кто-нибудь сказать мне, где я ошибаюсь? Не стесняйтесь объяснить, если хотите, поскольку я не сторонник Spring как такового. Спасибо.
Подробнее здесь: https://stackoverflow.com/questions/216 ... ter-method
Мобильная версия