spring mvc项目搭建

本文详细介绍如何使用IntelliJ IDEA和Maven搭建Spring MVC项目,包括项目创建、添加依赖、配置web.xml等步骤,并介绍了使用Spring Security进行权限验证的方法及数据库配置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

“百家拼”的spring mvc项目搭建的几步:

1.项目创建

    使用intellidea和maven进行项目创建。

New Project->Maven Module->Create from archetype->选择 maven archetype webapp。详细参考:http://sauron.blog.51cto.com/5231038/1269350

2.添加依赖

maven依赖需要向pom.xml文件里面添加dependency。可以根据需要到包名到http://mvnrepository.com/去搜索,里面有写好的dependency,直接复制过来。

3.配置web.xml

配置xml文件路径(这里放到了resources/spring路径下了):

<context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            classpath*:spring/applicationContext*.xml
        </param-value>
    </context-param>
其他加载: http://zhxing.iteye.com/blog/399668

4.spring security

使用spring security进行权限验证,主要有:配置文件/数据库/LDAP。如果要结合使用,比如,使用本地数据库进行权限验证,使用LDAP进行密码验证可以参考:http://suene.iteye.com/blog/1831347 。核心是实现AuthenticationProvider接口,重写init和authenticate方法。并在xml如下配置:

<authentication-manager alias="authenticationManager">
        <authentication-provider ref="authenticationProvider" />
    </authentication-manager>

    <b:bean id="authenticationProvider" class="com.xxx.LdapAndDbAuthenticationProvider">
        <b:property name="authenticateByLdap" value="true" />
        <b:property name="passwordCompar" value="true" />
        <b:property name="url" value="ldap://${ldap.server.ip}:${ldap.server.port}" />
        <b:property name="userSearchBase" value="DC=xxx,DC=domain" />
    </b:bean>
 

5.数据库

使用ibitis进行映射,http://www.cnblogs.com/archie2010/archive/2011/05/06/2038792.html

6.项目部署

部署到jetty:http://hi.baidu.com/winterhome/item/713061dfde287fe5b3f777d0

7.spring标签注解

http://www.ibm.com/developerworks/cn/opensource/os-cn-spring-iocannt/

8.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值