1 通过Maven的形式导入用到的JAR包坐标
org.springframework
spring-context
5.0.2.RELEASE
commons-logging
commons-logging
1.2
log4j
log4j
1.2.12
junit
junit
4.12
test
com.alibaba
druid
1.1.10
mysql
mysql-connector-java
5.1.6
2 查看MySQL的表结构
7 编写测试类
@Test
public void test3(){
ApplicationContext ac=new ClassPathXmlApplicationContext("applicationContext.xml");
MyIpServiceImpl myipservice = ac.getBean("myipservice", MyIpServiceImpl.class);
List all_ip = myipservice.getAll_IP();
for(MyIp myIp:all_ip){
System.out.print(myIp.getIp_address()+" ");
System.out.println(myIp.getIp_date());
}
}
8 运行结果