配置spring+springMVC+mybatis+oracle

项目结构:

配置spring+springMVC+mybatis+oracle_第1张图片

1. applicationContext.xml



							
	
	
	
	
	
	
	
		
		
		
		
		
		
	
	
	
		
		
		
		
	
	
	
	
		
	
	
	
	
		
	
	
	
	

	

2. springmvc.xml



		   					   
	
	
	
	
	
	
	
	
	
		
		
	
	

3. sqlMapConfig.xml





    
	
		
	

4. db.properties

jdbc.driver=oracle.jdbc.driver.OracleDriver
jdbc.url=jdbc:oracle:thin:@127.0.0.1:1521:orcl
jdbc.username=scott
jdbc.password=302030

5. Controller.java

@Controller
public class HelloWorldController {
	
	private EmpService empService;
	
	@Autowired
	public void setEmpService(EmpService empService) {
		this.empService = empService;
	}

}

6. Mapper

package com.spring.mvc.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Select;

import com.spring.mvc.entity.Emp;

public interface EmpMapper {

	@Select("SELECT * FROM EMP")
	List findAll();
	
}

7. ServiceImpl

@Service
public class EmpServiceImpl implements EmpService {

	@Autowired
	private EmpMapper empMapper;
	
	@Override
	public List findAll() {
		return empMapper.findAll();
	}
	
}

 

你可能感兴趣的:(SSM)