1 用户表:
 2 create table t_user(
 3     user_id INT AUTO_INCREMENT PRIMARY KEY,
 4     user_name varchar(30),
 5     password varchar(32),
 6     last_visit datetime,
 7     last_ip varchar(23)
 8 )ENGINE=InnoDB;
 9 
10 创建用户登录日志表:
11 create table t_login_log(
12     login_log_id int auto_increment primary key,
13     user_id int,
14     ip varchar(23),
15     login_datetime datetime
16 )ENGINE=InnoDB;
17 
18 
19 初始化数据
20 inset into t_user(user_name,password) values('admin','123456')

 

 1.

 

 

2.

 1 package com.asm;
 2 
 3 public class HelloWorld {
 4     private String name;
 5 
 6     public void setName(String name) {
 7         this.name = name;
 8     }
 9 
10     public void printHello() {
11         System.out.println("Spring 3 : Hello ! " + name);
12     }
13 }

 

3.

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <beans xmlns="http://www.springframework.org/schema/beans"
 3     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 4     xsi:schemaLocation="http://www.springframework.org/schema/beans
 5     http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
 6 
 7     <bean id="helloBean" class="com.asm.HelloWorld">
 8         <property name="name" value="Yiibai" />
 9     </bean>
10 
11 </beans>

 

4.

 1 package com.asm;
 2 
 3 import org.springframework.context.ApplicationContext;
 4 import org.springframework.context.support.ClassPathXmlApplicationContext;
 5 
 6 public class App {
 7     public static void main(String[] args) {
 8         ApplicationContext context = new ClassPathXmlApplicationContext(
 9                 "applicationContext.xml"); HelloWorld obj = (HelloWorld) context.getBean("helloBean");
10         obj.printHello();
11     }
12 }

 

5.输出结果

Spring 3 : Hello ! Yiibai
posted on 2016-06-17 11:09  Sharpest  阅读(213)  评论(0)    收藏  举报