用idea写maven_SSM项目配置+增加+删除+查所有+非空验证+获取下拉列表值

在这里插入图片描述在这里插入图片描述
applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.springframework.org/schema/context
       http://www.springframework.org/schema/context/spring-context.xsd
       http://www.springframework.org/schema/tx
       http://www.springframework.org/schema/tx/spring-tx.xsd
       http://www.springframework.org/schema/aop
       http://www.springframework.org/schema/aop/spring-aop.xsd">
      
      <!-- DAO层配置 -->
      
      <!-- 加载外部数据库属性文件 -->
      <context:property-placeholder location="classpath:jdbc.properties"/>
      <!-- 配置数据源 -->
      <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
      	<property name="driverClass" value="${jdbc.driver}"></property>
      	<property name="jdbcUrl" value="${jdbc.url}"></property>
      	<property name="user" value="${jdbc.username}"></property>
      	<property name="password" value="${jdbc.password}"></property>
      </bean>
      <!-- 配置SqlSessionFactory -->  
      <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
      	<property name="dataSource" ref="dataSource"></property>

      	<!-- 引入sqlMapConfig.xml文件 -->
        <property name="configLocation" value="classpath:sqlMapConfig.xml"></property>
      	<!-- 配置别名 -->
      	<property name="typeAliasesPackage" value="cn.hp.entity"></property>
      </bean>
      
       <!-- 扫描DAO层接口的包,创建动态代理对象,存入到spring容器中 -->
       <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
       	<property name="basePackage" value="cn.hp.dao"></property>
       </bean>
       
       <!-- 业务层 -->
       
       <!-- 开启注解 -->
       <context:component-scan base-package="cn.hp.service"/>
       <!-- 配置事务管理器 -->
       <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
       	<!-- 注入数据源 -->
       	<property name="dataSource" ref="dataSource"></property>
       </bean>
       <!-- 开启事务注解 -->
       <tx:annotation-driven/>
  		
  		<!-- 日志 -->
  		<!--<bean id="logController" class="cn.hp.log.LogController"></bean>

  		<aop:config>
  			<aop:pointcut expression="execution(* cn.hp.controller.*.*(..))" id="pc"/>
  			<aop:aspect ref="logController">
  				<aop:around method="around" pointcut-ref="pc"/>
  			</aop:aspect>
  		</aop:config>-->
</beans>

jdbc.properties

jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/mydb
jdbc.username=root
jdbc.password=123456

spring-mvc.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xmlns:context="http://www.springframework.org/schema/context"
        xmlns:mvc="http://www.springframework.org/schema/mvc"
        xmlns:aop="http://www.springframework.org/schema/aop"
    	xmlns:security="http://www.springframework.org/schema/security"
        xsi:schemaLocation="http://www.springframework.org/schema/beans 
        http://www.springframework.org/schema/beans/spring-beans.xsd 
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context.xsd 
        http://www.springframework.org/schema/mvc 
        http://www.springframework.org/schema/mvc/spring-mvc.xsd
        http://www.springframework.org/schema/aop
    	http://www.springframework.org/schema/aop/spring-aop.xsd
    	http://www.springframework.org/schema/security
    	http://www.springframework.org/schema/security/spring-security.xsd">
		        
        <!-- 扫描控制器 -->
        <context:component-scan base-package="cn.hp.controller"/>
        <!-- 注解驱动:处理器适配器和处理器映射器 -->
        <mvc:annotation-driven conversion-service="conversionService"/>
        <!-- 视图解析器 -->
<!--        <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">-->
<!--                <property name="prefix" value="/pages/"></property>-->
<!--                <property name="suffix" value=".jsp"></property>-->
<!--        </bean>-->
        
        <!-- 文件上传 -->
        
        <!-- 拦截器 -->
        <!-- 自定义类型转换器 -->
        <bean id="conversionService" class="org.springframework.context.support.ConversionServiceFactoryBean">
        	<property name="converters">
        		<set>
        			<bean class="cn.hp.converter.StringToDateConverter"></bean>
        		</set>
        	</property>
        </bean>
        <!-- 静态资源全部放行 -->
        <mvc:default-servlet-handler/>
		
		<!-- aop的自动代理 -->
		<!--<aop:aspectj-autoproxy proxy-target-class="true"></aop:aspectj-autoproxy>-->
		<!--配置开启security的注解支持-->
		<!--<security:global-method-security secured-annotations="enabled"/>-->

</beans>

sqlMapConfig.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
  PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
  "http://mybatis.org/dtd/myb
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值