component-scan扫描不到其他module下的包路径
尝试按教程:Spring+Spring MVC+MySQL的简单开发
用IDEA+SpringMVC+Tomcat+MySQL做一个登录demo。
但是配置ApplicationContext文件的时候,使用<context:component-scan base-package="******"/>扫描时无法识别其他模块下的类。
于是登录一直出错
项目结构:


smart-context.xml 文件
smart-servlet.xml 文件
查到了一个解决办法,但是不太明白:component-scan扫描不到其他module下的包路径
求教
用IDEA+SpringMVC+Tomcat+MySQL做一个登录demo。
但是配置ApplicationContext文件的时候,使用<context:component-scan base-package="******"/>扫描时无法识别其他模块下的类。
于是登录一直出错
项目结构:


smart-context.xml 文件
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.0.xsd">
<!--扫描类包,将标注为注解的类自动转化为Bean,同时完成Bean的注入--> smart 、dao、service无法识别
<context:component-scan base-package="com.smart.dao"/>
<context:component-scan base-package="com.smart.service"/>
<!-- dataSource 配置 -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" primary="true">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<!-- mysql6.0.x以上需要指定时区 -->
<property name="url" value="jdbc:mysql://localhost:3306/sampledb?serverTimezone=UTC" />
<property name="username" value="root" />
<property name="password" value="123456" />
</bean>
<!-- 引入jdbc配置文件 -->
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource" ref="dataSource"/>
</bean>
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<aop:config proxy-target-class="true">
<aop:pointcut id="serviceMethod" expression="(execution(* com.smart.service..*(..))) and
(@annotation(org.springframework.transaction.annotation.Transactional))" />
<aop:advisor pointcut-ref="serviceMethod" advice-ref="txAdvice" />
</aop:config>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="*"/>
</tx:attributes>
</tx:advice>
</beans>smart-servlet.xml 文件
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd">
<context:component-scan base-package="com.smart.web"/>
smart和web两个包都无法识别
<!--配置视图解析器,将ModelAndView及字符串解析为具体页面-->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/" /> prefix和sufix两个属性也无法识别
<property name="suffix" value=".jsp" />
</bean>
</beans>
查到了一个解决办法,但是不太明白:component-scan扫描不到其他module下的包路径
求教

...全文
相关推荐
SSM框架搭建步骤
里面有SSM框架搭建的全部过程。.....................
软件测试常用专业英语.doc
软件测试常用专业英语.doc
LCD资料集合(含程序).doc
LCD资料集合(含程序)doc,该资源描述了LCD的一些专业术语的解释,并且为网友提供了相关程序代码的展示
正交拉丁超立方(OLHC)分组与实验设计(DOE)评估的优化Python实现.rar
正交拉丁超立方(OLHC)分组与实验设计(DOE)评估的优化Python实现.rar
Java微服务如何拆解审计日志查询服务
标题:Java微服务如何拆解审计日志查询服务 内容概要:围绕缓存策略、任务调度、回压控制和审计追踪,拆解Java微服务如何拆解审计日志查询服务的实现细节。 xdronline.com xdrea.com 9g.xinmei6.com xinghaohuanbao.com m.xiker66.com


Web 开发
