Java 导出jar文件后引发Spring NoSuchBeanDefinitionException异常
我有一个spring项目,我可以在导出jar文件之前从spring上下文中获取Springbean。我导出jar文件并在cmd上运行该jar文件。我得到了Java 导出jar文件后引发Spring NoSuchBeanDefinitionException异常,java,spring,jar,Java,Spring,Jar,我有一个spring项目,我可以在导出jar文件之前从spring上下文中获取Springbean。我导出jar文件并在cmd上运行该jar文件。我得到了没有这样的定义异常。项目找不到Springbean。我在spring配置文件中使用了。我想知道问题出在哪里 编辑 在豆子里 package com.example.userprofile; @Service("UserProfileManager") @Transactional public class UserProfileManager
没有这样的定义异常
。项目找不到Springbean。我在spring配置文件中使用了
。我想知道问题出在哪里
编辑
在豆子里
package com.example.userprofile;
@Service("UserProfileManager")
@Transactional
public class UserProfileManagerImpl implements UserProfileManager{
@Autowired
private UserProfileDao userProfileDao;
在spring配置文件中
<context:component-scan
base-package="com.example" />
<tx:annotation-driven transaction-manager="transactionManager" />
<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" />
<bean id="transactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager"
p:sessionFactory-ref="sessionFactory" />
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource"
p:driverClassName="com.mysql.jdbc.Driver" p:url="jdbc:mysql://localhost:3309/test"
p:username="root" p:password="root" />
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation">
<value>hibernate.cfg.xml</value>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
</props>
</property>
</bean>
hibernate.cfg.xml
org.hibernate.dialogue.mysqldialogue
真的
真的
更新
当我用JBossIDE测试这个项目时,它工作得非常好。但是当我将项目导出到jar文件并在cmd上运行时。我犯了以下错误。
是我的项目压缩文件。很抱歉更新太晚。虽然问题陈述太宽,无法提供具体答案,但您可以执行以下操作:
如果什么也没跳出来,粘贴整个堆栈跟踪,不仅仅是代码片段,还包括jar的结构,这样我们也可以看到与您相同的整体情况。您可以粘贴您使用过的jar列表吗?请添加堆栈跟踪和相关代码。请添加您的配置xml和jar布局。您可以添加UserProfileManager的代码吗当我运行项目jar文件时,为什么会抛出异常?提示:查看IDE中的输出,查看它用于运行的类路径,并将其与类路径进行比较。我打赌建议1.如何检查jar文件中的类注释?