SSM框架整合
创始人
2024-06-03 13:35:15

一、先整合spring和mybatis:
      Junit测试jar(4.12版本)
      Mybatis(3.4.5)
      Spring相关的jar(spring-context、spring-tx、spring-jdbc、spring-test、spring-aop、                                                 aspectjweaver)
      mybatis、spring 整合包(mybatis-spring-x.x.x)
      Mysql数据库驱动包
      druid数据库连接池包

junitjunit4.12testorg.mybatismybatis3.4.5org.springframeworkspring-context5.1.12.RELEASEorg.springframeworkspring-tx5.1.12.RELEASEorg.springframeworkspring-test5.1.12.RELEASEorg.springframeworkspring-jdbc5.1.12.RELEASEorg.springframeworkspring-aop5.1.12.RELEASEorg.aspectjaspectjweaver1.8.11org.mybatismybatis-spring2.0.3mysqlmysql-connector-java5.1.35com.alibabadruid1.1.10

2、修改 appliactionContext.xml



3、jdbc.properties

jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://101.132.167.18:3306/mydatabase
jdbc.username=root
jdbc.password=root

4、引入springmvc及tomcat插件

org.apache.maven.pluginsmaven-compiler-plugin3.21.81.8UTF-8org.apache.tomcat.maventomcat7-maven-plugin2.280/

5、测试类编写

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath*:application*.xml"})
public class TestMyBatis {@Autowiredprivate AccountService accountService;@Testpublic void test(){System.out.println(accountService);Account accounts = accountService.queryAccount();//for (int i = 0; i < accounts.size(); i++) {System.out.println(accounts);//}}
}

相关内容

热门资讯

华凯易佰涨8.81%,成交额7... 1月12日,华凯易佰涨8.81%,成交额7.07亿元,换手率15.62%,总市值53.46亿元。异动...
美康生物涨0.88%,成交额4... 1月12日,美康生物涨0.88%,成交额4951.34万元,换手率1.65%,总市值39.51亿元。...
康弘药业涨0.17%,成交额5... 1月12日,康弘药业涨0.17%,成交额5.34亿元,换手率2.26%,总市值316.84亿元。异动...
国信证券涨0.52%,成交额6... 1月12日,国信证券涨0.52%,成交额6.27亿元,换手率0.49%,总市值1384.68亿元。异...
开立医疗涨1.66%,成交额1... 1月12日,开立医疗涨1.66%,成交额1.58亿元,换手率1.25%,总市值127.43亿元。异动...