SSM框架-Intellij IDEA

最近在搞一个SSM框架的基础工程,看到了一篇很详细的博客(博客地址)。但是他是基于Eclipse搭建的,在idea中运行异常,查阅资料修复后,分享给大家。

修改了什么?

pom.xml

编译时候需包含mybatis的xml文件

  <build>
    <finalName>ssm</finalName>
    <resources>
      <resource>
        <directory>src/main/java</directory>
        <includes>
          <include>**/*.xml</include>
        </includes>
      </resource>
    </resources>
  </build>

增加jackson-core-asl、jackson-core和jackson-databind

    <dependency>
      <groupId>org.codehaus.jackson</groupId>
      <artifactId>jackson-core-asl</artifactId>
      <version>1.9.13</version>
    </dependency>

    <dependency>
      <groupId>org.codehaus.jackson</groupId>
      <artifactId>jackson-mapper-asl</artifactId>
      <version>1.9.13</version>
    </dependency>

    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-core</artifactId>
      <version>2.5.1</version>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
      <version>2.5.1</version>
    </dependency>

spring-mvc.xml

mappingJacksonHttpMessageConverter修改为MappingJackson2HttpMessageConverter

    <!--<bean id="mappingJacksonHttpMessageConverter"-->
        <!--class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">-->
    <bean id="mappingJacksonHttpMessageConverter"
        class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
        <property name="supportedMediaTypes">
            <list>
                <value>text/html;charset=UTF-8</value>
            </list>
        </property>
    </bean>

AnnotationMethodHandlerAdapter修改为RequestMappingHandlerAdapter

    <!--<bean-->
        <!--class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">-->
    <bean
            class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"
            p:ignoreDefaultModelOnRedirect="true">
        <property name="messageConverters">
            <list>
                <ref bean="mappingJacksonHttpMessageConverter" />   <!-- JSON转换器 -->
            </list>
        </property>
    </bean>

增加annotation-driven

<mvc:annotation-driven />

如何使用本文Demo?

创建一个表

CREATE TABLE `sys`.`user_t` (
  `id` INT NOT NULL,
  `user_name` VARCHAR(45) NULL,
  `password` VARCHAR(45) NULL,
  `age` INT(4) NULL,
  PRIMARY KEY (`id`));

修改你的数据库连接

#jdbc.properties
driver=com.mysql.jdbc.Driver
#需要修改数据库地址
url=jdbc:mysql://localhost:3306/sys
#需要修改数据库账户名
username=root
#需要修改数据库密码
password=root
#定义初始连接数
initialSize=0
#定义最大连接数
maxActive=20
#定义最大空闲
maxIdle=20
#定义最小空闲
minIdle=1
#定义最长等待时间
maxWait=60000

示例代码下载

下载地址:
http://download.csdn.net/detail/yirentianran/9653593

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

胡矣

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值