学生成绩管理系统-SSM实现(一)——配置文件篇

学生成绩管理系统-SSM实现(配置文件的配置加注解)


(该项目使用maven管理)


  1. 所需jar包(pom.xml)
        
        <spring.version>4.3.9.RELEASEspring.version>
        <aspectj.version>1.6.11aspectj.version>
        <junit.version>4.12junit.version>
        <mysql.version>5.1.38mysql.version>
        <mybatis.version>mybatis.version>
        <mybatis-spring.version>1.3.1mybatis-spring.version>
        <mybatis.version>3.4.4mybatis.version>
        <jstl.version>1.2jstl.version>
        <jackson.version>1.9.13jackson.version>
        <fastjson.version>1.2.46fastjson.version>

        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-coreartifactId>
            <version>${spring.version}version>
        dependency>

        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-webartifactId>
            <version>${spring.version}version>
        dependency>

        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-oxmartifactId>
            <version>${spring.version}version>
        dependency>

        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-txartifactId>
            <version>${spring.version}version>
        dependency>

        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-jdbcartifactId>
            <version>${spring.version}version>
        dependency>

        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-webmvcartifactId>
            <version>${spring.version}version>
        dependency>

        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-aopartifactId>
            <version>${spring.version}version>
        dependency>

        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-context-supportartifactId>
            <version>${spring.version}version>
        dependency>


        

        
        <dependency>
            <groupId>mysqlgroupId>
            <artifactId>mysql-connector-javaartifactId>
            <version>${mysql.version}version>
        dependency>
                
        <dependency>
            <groupId>org.aspectjgroupId>
            <artifactId>aspectjrtartifactId>
            <version>${aspectj.version}version>
        dependency>
        
        <dependency>
            <groupId>org.aspectjgroupId>
            <artifactId>aspectjweaverartifactId>
            <version>${aspectj.version}version>
        dependency>
                
        <dependency>
            <groupId>org.mybatisgroupId>
            <artifactId>mybatis-springartifactId>
            <version>${mybatis-spring.version}version>
        dependency>
        <dependency>
            <groupId>org.mybatisgroupId>
            <artifactId>mybatisartifactId>
            <version>${mybatis.version}version>
        dependency>
        
        <dependency>
            <groupId>com.fasterxml.jackson.coregroupId>
            <artifactId>jackson-databindartifactId>
            <version>2.7.5version>
        dependency>
        <dependency>
            <groupId>org.codehaus.jacksongroupId>
            <artifactId>jackson-mapper-aslartifactId>
            <version>${jackson.version}version>
        dependency>
        <dependency>
            <groupId>org.codehaus.jacksongroupId>
            <artifactId>jackson-core-aslartifactId>
            <version>${jackson.version}version>
        dependency>
        
2. spring.xml
    
    <mvc:annotation-driven />

    
    <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">  
        <property name="messageConverters">  
            <list>  
                <ref bean="mappingJacksonHttpMessageConverter" />  
            list>  
        property>  
    bean>  
    <bean id="mappingJacksonHttpMessageConverter"
        class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
        <property name="supportedMediaTypes">
            <list>
                <value>text/html;charset=UTF-8value>
                <value>text/json;charset=UTF-8value>
            list>
        property>
    bean>


    
    
    <aop:aspectj-autoproxy />

    
    <tx:annotation-driven transaction-manager="transactionManager" />

    
    <bean id="dataSource"
        class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="com.mysql.jdbc.Driver" />
        <property name="url" value="" />
        <property name="username" value="" />
        <property name="password" value="" />
    bean>

    
    
    <bean id="transactionManager"
        class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource" />
    bean>

    
    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="typeAliasesPackage" value="com.mdy.student.bean" />
        
        <property name="configLocation" value="classpath:orm/mybatis-config.xml" />
        
        <property name="mapperLocations" value="classpath:mapper/*.xml" />
    bean>

    
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="com.mdy.student.mapper" />
    bean>
    
3.web.xml部分内容

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListenerlistener-class>
    listener>

    <servlet>
        <servlet-name>Studentservlet-name>
        <servlet-class>
            org.springframework.web.servlet.DispatcherServlet
        servlet-class>
        
        <init-param>
            <param-name>contextConfigLocationparam-name>
            
            <param-value>classpath*:spring/mvc-config.xmlparam-value>
        init-param>
        <load-on-startup>1load-on-startup>
    servlet>
    <servlet-mapping>
        <servlet-name>Studentservlet-name>
        <url-pattern>/url-pattern>
    servlet-mapping>
4.mvc-config.xml
<mvc:annotation-driven/>

    <context:component-scan base-package="com.mdy.student.web" />


    <mvc:resources mapping="/js/**" location="/resources/js/" cache-period="#{60 * 60}" />
    <mvc:resources mapping="/css/**" location="/resources/css/" cache-period="#{60 * 60}" />
    


    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    
        <property name="prefix" value="/WEB-INF/jsp/"/>
        
        <property name="suffix" value=".jsp"/>
    bean>

以上为该项目的配置文件的具体情况

你可能感兴趣的:(java,javaweb,ssm)