ssm框架实现查询需要什么配置

ssm框架实现查询需要什么配置


陪伴而非守候
浏览 736回答 1
1回答

隔江千里

不好讲,先给你看看我的配置文件吧spring-mybaits.xml里的内容:<!-- 定义dbcp组件DataSource --><bean id ="dbcp" class = "org.apache.commons.dbcp.BasicDataSource"><property name="username" value = "root"></property><property name="password" value = "36963"></property><property name="url" value = "jdbc:mysql://localhost:3306/cloud_note?useUnicode=true&characterEncoding=utf8"></property><property name="driverClassName" value = "com.mysql.jdbc.Driver"></property></bean><!--定义SqlSessionFactory注入dbcp,连接数据库,连接Mapper映射文件(SQL定义文件)--><bean id = "ssf" class = " org.mybatis.spring.SqlSessionFactoryBean"><property name="dataSource" ref = "dbcp"></property><property name="mapperLocations" value = "classpath:mapper/*.xml"></property></bean><!--定义MapperScannerConfigurer注入ssf,连接--><bean id = "mapperScanner"class = "org.mybatis.spring.mapper.MapperScannerConfigurer"><!-- dao包下都是mapper型,故不需要annocation --><property name="basePackage" value = "com.tedu.cloudnote.dao"></property><!--将ssf对象往里传,注入型sqlSessionFactory可以省略不写--><property name="sqlSessionFactory" ref = "ssf"></property></bean>然后是spring-mvc.xml内的内容:<!-- 定义HandlerMapping --><mvc:annotation-driven /><!-- 扫描Controller,Service组件 --><context:component-scanbase-package="com.tedu.cloudnote"/>还需要这么些个包:spring mvc,mybatis,mybatis-spring,driver,dbcp,junit,spring-jdbc
打开App,查看更多内容
随时随地看视频慕课网APP