10014基于SSM开发的酒店管理系统
代码:
鏈-椄:https://pan@baidu@com/s/1J6jgZDc60GVup3Se9NTpsw (把@换成 . 就可正常访问)
趧-紶-碼:9274
f/u枝此段-吶傛打开baidu網盤手机App,caozuo更方便哦
技术
Spring + SpringMVC + MyBatis
工具
eclipse + tomact + mysql + jdk
功能详情
前台功能 | 后台功能 |
---|---|
首页 | 系统设置 |
客房列表 | 用户管理 |
房间信息 | 系统日志 |
用户注册 | 楼层管理 |
我的订单 | 房型管理 |
我的资料 | 房间管理 |
修改密码 | 客户管理 |
预定管理 | |
入住管理 | |
营业统计 |
系统相关截图
● 前台首页
● 后台管理
domain实体类:
package com.liyan.domain;
import java.io.Serializable;
public class Account implements Serializable{
private Integer id;
private String name;
private Integer money;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getMoney() {
return money;
}
public void setMoney(Integer money) {
this.money = money;
}
@Override
public String toString() {
return "Account{" +
"id=" + id +
", name='" + name + '\'' +
", money=" + money +
'}';
}
}
dao接口:
package com.liyan.dao;
import com.liyan.domain.Account;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import java.util.List;
public interface IAccountDao {
@Select(“select * from account”)
List findAll();
@Insert("insert into account(name,money)values(#{name},#{money})")
void save(Account account);
}
service接口:
package com.liyan.service;
import com.liyan.domain.Account;
import java.util.List;
public interface IAccountService {
List findAll();
void save(Account account);
}
service实现类:
package com.liyan.service.impl;
import com.liyan.dao.IAccountDao;
import com.liyan.domain.Account;
import com.liyan.service.IAccountService;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service(“accountService”)
public class AccountServiceImpl implements IAccountService {
@Autowired
private IAccountDao accountDao;
public List<Account> findAll() {
return accountDao.findAll();
}
public void save(Account account) {
accountDao.save(account);
}
}
controller层代码:
package com.liyan.web.controller;
import com.liyan.domain.Account;
import com.liyan.service.IAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import java.util.List;
@Controller
@RequestMapping(“account”)
public class AccountController {
@Autowired
private IAccountService accountService;
@RequestMapping("save")
public String save(Account account){
accountService.save(account);
return "success";
}
@RequestMapping("findAll")
public ModelAndView findAll(){
List<Account>accounts=accountService.findAll();
System.out.println("查询了所有账户");
ModelAndView mv=new ModelAndView();
mv.setViewName("success");
mv.addObject("accounts",accounts);
return mv;
}
}
配置文件
applicationContext.xml:
<?xml version="1.0" encoding="UTF-8"?><context:component-scan base-package="com.liyan">
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"></context:exclude-filter>
</context:component-scan>
<context:property-placeholder location="classpath:jdbc.properties"></context:property-placeholder>
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
</bean>
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${jdbc.driver}"></property>
<property name="url" value="${jdbc.url}"></property>
<property name="username" value="${jdbc.username}"></property>
<property name="password" value="${jdbc.password}"></property>
</bean>
<bean id="mapperScannerConfigurer" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.liyan.dao"></property>
</bean>
<bean id="dataSourceTransactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"></property>
</bean>
<tx:advice id="txAdvice" transaction-manager="dataSourceTransactionManager">
<tx:attributes>
<tx:method name="*" read-only="false" propagation="REQUIRED"/>
<tx:method name="find*" read-only="true" propagation="REQUIRED"></tx:method>
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="pt1" expression="execution(* com.liyan.service.impl.*.*(..))"></aop:pointcut>
<!--<aop:advisor advice-ref="tx" pointcut-ref="pt1"></aop:advisor>-->
<aop:advisor advice-ref="txAdvice" pointcut-ref="pt1"></aop:advisor>
</aop:config>
jdbc.properties:
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/ssmtest
jdbc.username=root
jdbc.password=root
springmvc.xml:
<?xml version="1.0" encoding="UTF-8"?><context:component-scan base-package="com.liyan.web"></context:component-scan>
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/pages/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
<mvc:annotation-driven/>
success.jsp:
<%@ page contentType=“text/html;charset=UTF-8” language=“java” %>
web.xml:
<?xml version="1.0" encoding="UTF-8"?> org.springframework.web.context.ContextLoaderListener contextConfigLocation classpath:applicationContext.xml dispatcherServlet org.springframework.web.servlet.DispatcherServlet contextConfigLocation classpath:springmvc.xml 1 dispatcherServlet / characterEncodingFilter org.springframework.web.filter.CharacterEncodingFilter encoding UTF-8 characterEncodingFilter /*index.jsp:
<%@page contentType=“text/html; UTF-8” language=“java” pageEncoding=“UTF-8” %>
测试类:
Test01springIOC:
package com.liyan.test;
import com.liyan.service.IAccountService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class Test01SpringIOC {
public static void main(String[] args) {
ApplicationContext ac=new ClassPathXmlApplicationContext(“applicationContext.xml”);
IAccountService accountService=ac.getBean(“accountService”,IAccountService.class);
accountService.findAll();
}
}
Test02Mybatis:
package com.liyan.test;
import com.liyan.dao.IAccountDao;
import com.liyan.domain.Account;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import java.io.IOException;
import java.io.InputStream;
public class Test02Mybatis {
public static void main(String[] args) throws IOException {
InputStream in= Resources.getResourceAsStream(“SqlMapConfig.xml”);
SqlSessionFactoryBuilder builder=new SqlSessionFactoryBuilder();
SqlSessionFactory factory=builder.build(in);
SqlSession sqlSession=factory.openSession();
IAccountDao accountDao=sqlSession.getMapper(IAccountDao.class);
// Listaccounts=accountDao.findAll();
// for (Account account:accounts){
// System.out.println(account);
// }
Account account=new Account();
account.setName(“liyan”);
account.setMoney(20000);
accountDao.save(account);
sqlSession.commit();
sqlSession.close();
in.close();
}
}
Test03SpringMybatis:
package com.liyan.test;
import com.liyan.domain.Account;
import com.liyan.service.IAccountService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.List;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = “classpath:applicationContext.xml”)
public class Test03SpringMybatis {
@Autowired
private IAccountService accountService;
@Test
public void findAll(){
List<Account>accounts =accountService.findAll();
for (Account account:accounts){
System.out.println(account);
}
}
@Test
public void save(){
Account account=new Account();
account.setName("xiaoyanzi");
account.setMoney(55555);
accountService.save(account);
}
}
SqlMapConfig.xml:
<?xml version="1.0" encoding="UTF-8"?>pom包:
<?xml version="1.0" encoding="UTF-8"?>
4.0.0
com.liyan
ssm2Demo
1.0-SNAPSHOT
war