【发布时间】:2012-02-01 06:41:30
【问题描述】:
我有两个使用相同数据库对象的不同应用程序(站点 + 一些 cron 实用程序)。我将它们移动到单独的库中,并且在应用程序中我只留下了 hibernate.configuration 文件。
现在,问题是我有一些使用 JavaMailSender 的电子邮件通知服务,它在 spring 配置文件中定义了属性:
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host" value="mail.xxx.com" />
<property name="username" value="xxx" />
<property name="password" value="xxx" />
<property name="javaMailProperties">
<props>
<prop key="mail.smtp.auth">true</prop>
<prop key="mail.smtp.starttls.enable">true</prop>
<prop key="mail.smtp.ssl.trust">*</prop>
</props>
</property>
</bean>
<bean id="notificationsService" class="de.crm.NotificationsService">
<property name="sender" ref="mailSender" />
<property name="properties" ref="notificationsServiceProperties" />
</bean>
<bean id="notificationsServiceProperties" class="de.crm.objects.properties.NotificationsServiceProperties">
<property name="name" value="xxx" />
<property name="email" value="xxx" />
</bean>
所以这里的主要问题是它看不到 de.crm.objects.properties.NotificationsServiceProperties 类,因为它是在外部库中定义的并且项目在导出时失败。
有没有办法将属性类留在外部库中并修复它? 谢谢
UPD#1:是否可以使用带有 @Autowired 注释的外部库 Spring 中的对象?
【问题讨论】:
-
是外部jar添加到构建路径还是外部jar放在classpath中,从哪里可以读取?
-
我已在 Buildpath 设置中将外部 jar 添加为外部库
标签: java hibernate spring-mvc