環(huán)境:eclipse
目前創(chuàng)新互聯(lián)已為近千家的企業(yè)提供了網(wǎng)站建設(shè)、域名、虛擬空間、網(wǎng)站托管、服務(wù)器租用、企業(yè)網(wǎng)站設(shè)計(jì)、寧夏網(wǎng)站維護(hù)等服務(wù),公司將堅(jiān)持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長,共同發(fā)展。項(xiàng)目目錄:
jar包:
web.xml
spring-mybatis.xml
jdbc.properties
driver=com.mysql.jdbc.Driver url=jdbc:mysql://localhost/cec username=root password=root #\u5B9A\u4E49\u521D\u59CB\u8FDE\u63A5\u6570 initialSize=0 #\u5B9A\u4E49\u6700\u5927\u8FDE\u63A5\u6570 maxActive=20 #\u5B9A\u4E49\u6700\u5927\u7A7A\u95F2 maxIdle=20 #\u5B9A\u4E49\u6700\u5C0F\u7A7A\u95F2 minIdle=1 #\u5B9A\u4E49\u6700\u957F\u7B49\u5F85\u65F6\u95F4 maxWait=60000log4j.properties
#\u5B9A\u4E49LOG\u8F93\u51FA\u7EA7\u522B log4j.rootLogger=INFO,Console,File #\u5B9A\u4E49\u65E5\u5FD7\u8F93\u51FA\u76EE\u7684\u5730\u4E3A\u63A7\u5236\u53F0 log4j.appender.Console=org.apache.log4j.ConsoleAppender log4j.appender.Console.Target=System.out #\u53EF\u4EE5\u7075\u6D3B\u5730\u6307\u5B9A\u65E5\u5FD7\u8F93\u51FA\u683C\u5F0F\uFF0C\u4E0B\u9762\u4E00\u884C\u662F\u6307\u5B9A\u5177\u4F53\u7684\u683C\u5F0F log4j.appender.Console.layout = org.apache.log4j.PatternLayout log4j.appender.Console.layout.ConversionPattern=[%c] - %m%n #\u6587\u4EF6\u5927\u5C0F\u5230\u8FBE\u6307\u5B9A\u5C3A\u5BF8\u7684\u65F6\u5019\u4EA7\u751F\u4E00\u4E2A\u65B0\u7684\u6587\u4EF6 log4j.appender.File = org.apache.log4j.RollingFileAppender #\u6307\u5B9A\u8F93\u51FA\u76EE\u5F55 log4j.appender.File.File = logs/ssm.log #\u5B9A\u4E49\u6587\u4EF6\u6700\u5927\u5927\u5C0F log4j.appender.File.MaxFileSize = 10MB # \u8F93\u51FA\u6240\u4EE5\u65E5\u5FD7\uFF0C\u5982\u679C\u6362\u6210DEBUG\u8868\u793A\u8F93\u51FADEBUG\u4EE5\u4E0A\u7EA7\u522B\u65E5\u5FD7 log4j.appender.File.Threshold = ALL log4j.appender.File.layout = org.apache.log4j.PatternLayout log4j.appender.File.layout.ConversionPattern =[%p] [%d{yyyy-MM-dd HH\:mm\:ss}][%c]%m%nUserController.java
package hanxuanyuan.controller; import javax.annotation.Resource; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import hanxuanyuan.domain.User; import hanxuanyuan.service.UserService; @Controller @RequestMapping("/user") public class UserController { @Resource private UserService userService; @RequestMapping("/showUser") public String showUser(Model model){ User user = userService.selectByPrimaryKey("1") ; model.addAttribute("user",user) ; return "welcome" ; } }UserService.java
package hanxuanyuan.service; import hanxuanyuan.domain.User; public interface UserService { void insert(User record); User selectByPrimaryKey(String id); }UserServiceImpl.java
package hanxuanyuan.service; import javax.annotation.Resource; import org.springframework.stereotype.Service; import hanxuanyuan.dao.UserMapper; import hanxuanyuan.domain.User; @Service("userService") public class UserServiceImpl implements UserService{ @Resource private UserMapper userMapper ; @Override public void insert(User record) { userMapper.insert(record) ; } @Override public User selectByPrimaryKey(String id) { return userMapper.selectByPrimaryKey(id); } }UserMapper.java
package hanxuanyuan.dao; import hanxuanyuan.domain.User; public interface UserMapper { int deleteByPrimaryKey(String id); int insert(User record); int insertSelective(User record); User selectByPrimaryKey(String id); int updateByPrimaryKeySelective(User record); int updateByPrimaryKey(User record); }UserMapper.xml
userMapper,User,UserMapper.xml這三個(gè)文件是mybatis-generator自動生成的,http://pan.baidu.com/s/1cvQWsY
使用方法: (1)打開dos命令窗口,進(jìn)入到該目錄下,配置好generatorConfig.xml后,運(yùn)行命令:
java -jar mybatis-generator-core-1.3.2.jar -configfile generatorConfig.xml -overwrite
(2)拷貝文件到項(xiàng)目對應(yīng)位置
jar包鏈接:http://down.51cto.com/data/2302826
項(xiàng)目源碼鏈接: http://pan.baidu.com/s/1o7H6WUu
不推薦大家直接看源碼,自己參考以上代碼,看看能否自己搭出來
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。