package com.ztx.dao;
import com.ztx.entity.User;
/**
* Created by Think on 2016/10/19.
*/
public interface UserDao {
User selectById(String id);
}
10.UserMapper.xml
11.在spring-config.xml中配置Dao
每添加一个dao,就要在spring-config中配置
第五步:项目整体
目录结构
1.userAction.java
package com.ztx.action;
import com.ztx.entity.User;
import com.ztx.service.UserService;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import javax.annotation.Resource;
@ParentPackage("struts-default")
@Namespace("/") //命名空间为根目录
@Action(value = "userAction")
public class userAction {
@Resource(name = "userService")
private UserService userService;
public void test(){
System.out.println("进入了Action");
String id = "盖伦";
User u = userService.SelestPwdById(id);
System.out.println("pwd:"+u.getPwd());
}
}
2.UserService.java
package com.ztx.service;
import com.ztx.entity.User;
/**
* Created by Think on 2017/1/22.
*/
public interface UserService {
public void test();
public User SelestPwdById(String id);
}
3.UserServiceImpl.java
package com.ztx.service.impl;
import com.ztx.dao.UserDao;
import com.ztx.entity.User;
import com.ztx.service.UserService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@Service(value = "userService")
public class UserServiceImpl implements UserService {
@Resource(name="userDao")
private UserDao userDao;
@Override
public void test() {
System.out.println("测试spring");
}
@Override
public User SelestPwdById(String id) {
return userDao.selectById(id);
}
}
4.UserDao.java
package com.ztx.dao;
import com.ztx.entity.User;
/**
* Created by Think on 2016/10/19.
*/
public interface UserDao {
User selectById(String id);
}
5.实体类User.java
package com.ztx.entity;
import java.util.Date;
public class User {
private String id;
private String name;
private String pwd;
private Date createDateName;
private Date modifyDateTime;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPwd() {
return pwd;
}
public void setPwd(String pwd) {
this.pwd = pwd;
}
public Date getCreateDateName() {
return createDateName;
}
public void setCreateDateName(Date createDateName) {
this.createDateName = createDateName;
}
public Date getModifyDateTime() {
return modifyDateTime;
}
public void setModifyDateTime(Date modifyDateTime) {
this.modifyDateTime = modifyDateTime;
}
}
6.UserMapper.xml
TsetSpring.java
/*
import com.ztx.service.UserService;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class TestSpring {
@Test
public void test(){
//获得这个spring-config。
ApplicationContext ac = new ClassPathXmlApplicationContext
(new String[]{"classpath:\\com\\ztx\\config\\spring\\spring-config.xml"});
UserService userService= (UserService) ac.getBean("userService"); //调用bean 强转
userService.test();
}
}
*/
public class Server
{
//用来存储所有连接上来的客户
private List<ServerThread> clients;
public static void main(String[] args)
{
Server s = new Server();
s.startServer(9988);
}
publi
I got serveral questions about auto.offset.reset. This configuration parameter governs how consumer read the message from Kafka when there is no initial offset in ZooKeeper or
two cursors.
Make the first cursor go K steps first.
/*
* 第 13 题:题目:输入一个单向链表,输出该链表中倒数第 k 个节点
*/
public void displayKthItemsBackWard(ListNode head,int k){
ListNode p1=head,p2=head;
一、sh 脚本不执行的原因
sh脚本不执行的原因 只有2个
1.权限不够
2.sh脚本里路径没写完整。
二、解决You have new mail in /var/spool/mail/root
修改/usr/share/logwatch/default.conf/logwatch.conf配置文件
MailTo =
MailFrom
三、查询连接数
$ git push joe prod-2295-1
To [email protected]:joe.le/dr-frontend.git
! [rejected] prod-2295-1 -> prod-2295-1 (non-fast-forward)
error: failed to push some refs to '[email protected]