我不是在写setter getter而是使用autowire而不是出现以下错误 -
<?php
declare(ticks = 1);
$username = "user";
$password = "password";
$host = 'localhost:/home/firebird/base/base.gdb';
$sockets = array();
$dbh = ibase_connect($host, $username, $password);
function event_handler($event_name, $link) {
echo $event_name . "\n";
send_message($event_name);
}
# we need to unregister event in firebird before exit
function terminate($signal) {
global $event;
if (is_null($event)) {
die ( "no event has been registered yet, exiting" );
} else {
ibase_free_event_handler($event);
die ( "unregistered evented and exiting\n" );
}
}
function send_message($msg)
{
$localsocket = 'tcp://127.0.0.1:8010';
$instance = stream_socket_client ($localsocket, $errno, $errstr);
fwrite($instance, json_encode(['message' => $msg, 'userId' => 824]) . \n");
}
$event = ibase_set_event_handler($dbh, "event_handler", "schedule_update");
pcntl_signal(SIGTERM, "terminate");
while (true) {
sleep(1);
}
?>
我的 Spring-conf.xml
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'aS400Statusfacade' defined in class path resource [CXF-Bean.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'aS400StatusDAO' of bean class [com.metlife.mymet.admin.facade.AS400Statusfacade]: Bean property 'aS400StatusDAO' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1279)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(AccessController.java:250)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
我的班级用autowire -
<bean id="aS400Statusfacade"
class="com.metlife.mymet.admin.facade.AS400Statusfacade">
<property name="aS400StatusDAO" ref="aS400StatusDAO"></property>
</bean>
答案 0 :(得分:1)
我认为你遇到的问题是没有setter和一个显式标签Spring不知道你想从中得到什么。
尝试删除显式属性元素。
这将允许@Autowired注释尝试解析值。
进一步说明:
弹簧conf.xml中
<datasource jndi-name="java:/TCC/CSEDS" pool-name="CSEDS" enabled="true" use-java-context="true" use-ccm="true">
<connection-url>jdbc:sqlserver://172.17.33.21:1435;DatabaseName=CSE_DEV;SelectMethod=cursor</connection-url>
<driver>sqljdbc4.jar</driver>
<pool>
<min-pool-size>2</min-pool-size>
<max-pool-size>20</max-pool-size>
<prefill>true</prefill>
</pool>
<security>
<user-name>apxxxxx</user-name>
<password>CseUserxxxxx</password>
</security>
</datasource>
<datasource jndi-name="java:/TCC/NEWECDS" pool-name="NEWECDS" enabled="true" use-java-context="true" use-ccm="true">
<connection-url>jdbc:sqlserver://172.17.32.81:1738;DatabaseName=CCCECST2;SelectMethod=cursor</connection-url>
<driver>sqljdbc4.jar</driver>
<pool>
<min-pool-size>2</min-pool-size>
<max-pool-size>20</max-pool-size>
<prefill>true</prefill>
</pool>
<security>
<user-name>apedxxxx</user-name>
<password>Ecgxxxx</password>
</security>
</datasource>
<drivers>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
<driver name="sqljdbc4.jar" module="com.microsoft"/>
</drivers>
</datasources>
My spring configuration:
<bean id="newECDS" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>java:/TCC/NEWECDS</value>
</property>
</bean>
AS400Statusfacade插图
<bean id="aS400Statusfacade"
class="com.metlife.mymet.admin.facade.AS400Statusfacade">
<!--
The following property tag is not necessary. Spring's
@Autowired and associated bean post-processor, will introspect
and set the property with an appropriate candidate bean.
Bean property setter, is not required for the post-processor
to access/set the property.
-->
<!--
<property name="aS400StatusDAO" ref="aS400StatusDAO"></property>
-->
</bean>