springmvc+spring+mybatis工程搭建

《Hadoop大数据技术原理与应用》(第2版)黑马程序员的课后习题答案 阅读详情

1.新建maven webapp工程,配置pom文件

 1.1添加tomcat插件

<plugins>
  <plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.2</version>
    <configuration>
      <server>tomcat7</server>
      <update>true</update>
      <port>8080</port>
      <path>/</path>
    </configuration>
  </plugin>
</plugins>

 

 

 1.2配置文件扫描,将路径中的xml文件,properities文件,ini文件添加到classpath中

<resources>

  <resource>

    <directory>src/main/java</directory>

    <includes>

      <include>**/*.xml</include>

    </includes>

    <filtering>true</filtering>

  </resource>

  <resource>

    <directory>src/main/resources</directory>

    <includes>

      <include>**/*.properties</include>

      <include>**/*.xml</include>

      <include>**/*.ini</include>

    </includes>

    <filtering>false</filtering>

  </resource>

  </resources>

 

2.pom文件添加各个框架所需要的依赖jar包

  2.1添加spring


  <dependency>

  <groupId>org.springframework</groupId>

  <artifactId>spring-context</artifactId>

  <version>5.0.8.RELEASE</version>

  </dependency>

 

 

  2.2添加spring_webmvc(springmvc)

<!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-webmvc</artifactId>
  <version>5.0.8.RELEASE</version>
</dependency>

 

 

  2.3添加mybatis


<dependency>
  <groupId>org.mybatis</groupId>
  <artifactId>mybatis</artifactId>
  <version>3.4.6</version>
</dependency>

 

 

  2.4添加mysql


<dependency>
  <groupId>mysql</groupId>
  <artifactId>mysql-connector-java</artifactId>
  <version>5.1.34</version>
</dependency>

 

 

 

  2.5添加spring_mybatis

<dependency>
  <groupId>org.mybatis</groupId>
  <artifactId>mybatis-spring</artifactId>
  <version>1.3.2</version>
</dependency>

 

 

  2.6添加servlet

<!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
<dependency>
  <groupId>javax.servlet</groupId>
  <artifactId>javax.servlet-api</artifactId>
  <version>4.0.1</version>
  <scope>provided</scope>
</dependency>

 

 

  

  2.7添加数据库连接池,使用阿里的druid


<dependency>
  <groupId>com.alibaba</groupId>
  <artifactId>druid</artifactId>
  <version>1.1.10</version>
</dependency>

 

 

  2.8添加json,使用谷歌的jackson


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

 

 

  2.9添加aspectj


<dependency>
  <groupId>org.aspectj</groupId>
  <artifactId>aspectjweaver</artifactId>
  <version>1.9.1</version>
</dependency>

 

 

 

2.10添加spring_jdbc,用来读取properities,连接数据库


<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-jdbc</artifactId>
  <version>5.0.8.RELEASE</version>
</dependency>

 


 

 

3.创建工程目录结构

3.1在java文件夹下创建dao、service、controller、pojo、utils文件夹

3.2在resources文件夹下创建spring、mybatis、resource文件夹

 

4.创建各种配置文件,资源文件

4.1配置mybatis_config.xml

在mybatis文件夹下新建文件mybatis_config.xml,添加头:

<?xml version="1.0" encoding="UTF-8" ?>
        
<!DOCTYPE configuration
                PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
                "http://mybatis.org/dtd/mybatis-3-config.dtd">

工程使用spring托管mybatis,所以mybatis的配置文件只需要配置一下插件,数据库的连接放在spring的配置文件中

 

4.2配置properities文件

 在resource文件夹下新建db.properities文件,用来储存相关变量

mydriver=com.mysql.jdbc.Driver
myurl=jdbc:mysql://localhost:3306/world
myusername=数据库用户名 
mypassword=数据库密码
maxCreateTaskCount=100
minIdle=5

 

4.3配置spring的xml文件

4.3.1配置dao层的spring文件

<?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"
       
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">
    <!--引入配置文件,扫描注解-->
    
<context:property-placeholder location="classpath:resource/db.properties"/>
    <context:component-scan base-package="usts.dao"/>

    <!--配置数据库连接池-->
    
<bean id="dataSource"class="com.alibaba.druid.pool.DruidDataSource">
        <property name="driver" value="${mydriver}"/>
        <property name="url" value="${myurl}"/>
        <property name="username" value="${myusername}"/>
        <property name="password" value="${mypassword}"/>
        <property name="maxCreateTaskCount"value="${maxCreateTaskCount}"/>
        <property name="minIdle" value="${minIdle}"/>
    </bean>

    <!--配置sqlSessionFactory-->
    
<bean id="sqlSessionFactoryBean"class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="configLocation"value="classpath:mybatis/mybatis_config.xml"/>
        <property name="mapperLocations"value="classpath:usts/dao/*Mapper.xml"/>
    </bean>

    <!--spring托管mybatis-->
    
<bean id="mapperScannerConfigurer"class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="usts.dao"/>
    </bean>
</beans>

 

 

4.3.2配置service的spring文件

<?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"
       
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">

    <!--添加注解扫描-->
    
<context:component-scan base-package="usts.service"/>
</beans>

 

 

4.3.3配置事务的spring文件

<?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: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/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">

    <!--配置事务管理器-->
    
<bean id="dataSourceTransactionManager"class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource"/>
    </bean>
    <!--事务的详细配置-->
    <!--通知的详细配置-->
    
<tx:advice id="adv">
        <tx:attributes>
            <tx:method name="*" propagation="REQUIRED"/>
        </tx:attributes>
    </tx:advice>
    <!--配置aop,通知,切入点-->
    
<aop:config>
        <aop:pointcut id="point" expression="execution(* usts.service.*.*(..))"/>
        <aop:advisor advice-ref="adv" pointcut-ref="point"/>
    </aop:config>
</beans>

 

 

4.3.4配置springmvc的配置文件

<?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"
       
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">

    <context:component-scan base-package="usts.controller"/>
    <mvc:annotation-driven/>
    <mvc:default-servlet-handler/>

    <bean id="resourceViewResolver"class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="suffix" value=".html"/>
        <property name="prefix" value="/"/>
    </bean>
    <bean id="multipartResolver"class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
        <property name="defaultEncoding" value="utf-8"></property>
        <property name="maxUploadSize" value="100000"></property>
    </bean>
</beans>

 

 

 

5.web.xml的配置

5.1添加springmvc的servlet

<servlet>
  <servlet-name>dispatcherServlet</servlet-name>
  <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  <init-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:spring/springmvc_config.xml</param-value>
  </init-param>
</servlet>
<servlet-mapping>
  <servlet-name>dispatcherServlet</servlet-name>
  <url-pattern>/</url-pattern>
</servlet-mapping>

 

 

5.2配置启动项

<web-app>
  <display-name>Archetype Created Web Application</display-name>
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
      classpath:spring/spring_config_*.xml
   
    </
param-value>
  </context-param>
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>

MVSNet (pytorch版) 搭建环境 运行dtu数据集重建 实操教程(图文并茂、超详细) MVSNet (pytorch版) 代码注释版 下载 (注释非常详细,代码结构有所调整,使用起来更方便) 深度学习三维重建 MVSNet-ECCV-2018 (源码、pytorch版、原文+注释、译文+批注)Meshlab查看三维点云时 ,使用技巧总结。 阅读详情

相关推荐

App inventor2通过蓝牙控制Arduino Uno LED开关

App inventer2控制Arduino Uno LED开关 如果学会这个小程序,大部分的手机通过蓝牙控制Arduino的功能都可以实现,这个小示例是通过蓝牙模块向Arduino发送"0"和"1",而其它功能要发送其它不同的字符串内容给Arduino. 所需硬件: Arduino Uno JDY-16 蓝牙模块(我的是蓝牙4.2版本) 草帽LED(可选) 手机(我用的是安卓,苹果手机应该也可以,最近其应用商店也有App inventor(AI)伴侣) 软件: Aduino IDE或者Platfom

Firmin123456的博客 5498

SpringMVC框架+spring框架+Mybatis框架(SSM框架整合)

1.1原始方法整合 1.准备工作 2.创建Maven项目

weixin_61491281的博客 2381

ubuntu20.04安装Qt5.15.2并配置环境

qt官方取消了离线安装的方式,所以推荐在线安装,当然,如果想要自己通过源码编译也可以,参考官方文档:https://wiki.qt.io/Building_Qt_5_from_Git。 在线安装: 1.到官方网站下载:wget https://download.qt.io/official_releases/online_installers/qt-unified-linux-x64-online.run 2.修改文件权限:chmod 777 qt-unified-linux-x64-online.run

f120854632的博客 8807

Spring+SpringMVC+MyBatis

Web全栈实训三大框架笔记

m0_58642116的博客 1570

RAGFlow源码解析-2、从源码构架ragflow v0.25.0镜像

本文详细记录了从零开始构建自定义RAGFlow镜像lt/ragflow:0.25.0的全过程。首先介绍了环境准备,包括检查Node.js、Docker版本和项目结构。然后详细说明了构建步骤:编译前端、创建自定义Dockerfile、构建镜像和验证。接着讲解了docker-compose配置修改要点,包括网络定义、MySQL依赖处理等。最后总结了部署过程中遇到的五个关键问题及解决方案,包括networks未定义、MySQL服务依赖、tiktoken文件缺失、数据库配置错误和端口映射问题。通过完整的操作流程和问

liutao841204的专栏 364

应用处理器(AP)、系统级芯片(SoC)与微控制器(MCU)的区别与联系

应用处理器(AP)、系统级芯片(SoC)与微控制器(MCU)的区别与联系

a_zxswer的博客 1689

Druid连接报错的原因分析笔记

在使用druid的时候难免会有一些问题,之前就发现了这个问题。但是作者发现其对业务没有影响,所以打算拖一拖。主要是不影响业务,就会会频繁的报错。今天组内其他同学的业务的报错,然后也没定位...

tianjingle 1万+

STM32入门教程:智能马桶盖控制

通过编写相应的代码,您可以根据需要实现其他功能,例如座圈温度调节和液晶显示屏显示等。初始化配置 首先,使用STM32CubeMX创建一个新的工程,并选择您所使用的STM32单片机型号。智能马桶盖是一种集成了多种功能的智能家居设备,通过控制芯片来实现自动冲水、座圈加热、座圈温度调节等功能。在本教程中,我们将使用STM32系列单片机来控制智能马桶盖的各个功能。以上代码演示了如何通过STM32的GPIO控制引脚来控制智能马桶盖的冲水和座圈加热功能。写代码 接下来,我们将通过编写代码来控制智能马桶盖的各个功能。

2401_85258012的博客 657

Spring + MyBatis + SpringMVC 全面详解(学习笔记)

Spring + MyBatis + SpringMVC 全面详解(学习笔记)

as1517的博客 4419

【YoloV12改进策略】基于流形约束超连接(mHC)增强YoloV12全局特征提取能力_独家复现_梁文峰署名论文

论文标题:流形约束超连接 (Manifold-Constrained Hyper-Connections, mHC)核心问题:针对超连接 (Hyper-Connections, HC) 扩展残差流宽度时破坏恒等映射、引发训练不稳定性和高内存开销的问题,提出一种约束性框架。目标:恢复残差连接的稳定性与可扩展性,同时保持HC的性能增益。基准模型:基于DeepSeek-V3的MoE架构,进行了3B、9B、27B模型的实验验证。论文图示mHC 是一个通用的HC扩展框架。

m0_47867638的博客 1353

uniapp+renderJS+google map开发安卓版APP非小程序

uniapp+renderJS+google map开发安卓版APP非小程序,google map小叉号不显示,google map自定义marker右上角的小叉号如何去掉,uniapp+google map不显示

renkai721的专栏 667

Spring+SpringMVC+MyBatis框架整合的配置

不扯那些有的没的,夸赞的话我们上官网去看,这里只总结一些关于Spring框架的东西。通俗点来说,所谓的轻量级,就是没有那么繁琐了,至于JavaEE,它只是j2EE的另一个名称,指代的是企业版。剩下的还有j2SE和J2ME,分别是标准版和用于移动设备、嵌入式设备上的Java应用程序。以上是Spring框架的一些特性,重在理解。控制反转,就是把创建对象的过程交给Spring进行管理,在应用开发场景中,我们会使用到Spring的注解,类似与@Bean、@controller、@Service、@Component

fzt12138的博客 1503

AMS TMF8820/21/28 SPAD 掩码和模式选择

为了实现最快的测距周期,将报告周期设置在测距周期以下的毫秒,以确保不会有等待时间。除了8X8固定了pixel的位置意外,其他模式客户可以设计自己的spad掩码,并将spad单独分配给通道。对于这些spad掩码,有一些约束。左下角提示红色代表光学中心,绿色方框表示单个spad,每个MP里可能有2X3个spad,也有2X5个spad,也有3X6+3个spad,这部分适配光学,最大的程度的利用spad区域。以下是几种预定义的spad掩码,非常灵活的配置,来适配各种3X3,4X4,8X8的模式选择。

dream it possible 700

自己搭建spring-springmvc-mybatis工程

实习以来,一直在用springmvc,但是从来没有自己搭建过一个项目,特别是一直在用jpa做简单的加载,数据库也一般是在使用es,redis,hbase这些,没有用到hibernate和mybatis这两个主流的数据库映射框架,现在就来自己搭一个idea搭建起来的,坐落在tomcat上的demo。---idea真是好用到飞起,就是有一些配置不太好配,不错coding事非常好用啊!!! sprin

温柔而已 446

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

Spring、SpringMVC、Mybatis整合之工程的搭建

SSM框架整合之环境配置部分 学习完了Spring、SpringMVC、Mybatis框架,我们就可以尝试系统将三者进行整合。整合并不复杂,我们只需要实现最基础的配置,即可轻松的掌握SSM框架是如何实际项目中使用的。 基于上一篇博文:maven起步,我们应该知道了如何搭建maven项目,那么在此基础上,手把手教你搭建Spring、SpringMVC、Mybatis框架的环境。 源码请 点击这里...

weixin_44048532的博客 216

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

Spring+SpringMVC+MyBatis框架一个简单工程的搭建实例

最近一直项目中一直在使用Spring+SpringMVC+Mybatis 框架,根据自己对这三个框架的了解搭建了一个这样的工程(工程测试可用),期间遇到不少问题,跟大家分享下。    文章分成两大模块:      一、工程代码模块;    二、配置信息和自我理解模块。     项目的工程目录结构是: 一、工程代码模块: UserController.class package c

u011991249的专栏 1万+

SIMATIC S7-1200, S7-1500 PID 控制[手册]

SIMATIC S7-1200, S7-1500 PID 控制[手册]

如何建立java ssm工程_如何搭建SSM(SpringMvc+mybatis+Spring)java web工程

No.1 首先将web工程结构建好1.1.1 开发环境介绍在这里我是采用的是MySQL数据库编译器版本采用的是jdk使用的是1.8开发工具是使用的是eclipse Mars版本web容器采用的是tomcat 版本是7.0版本在这里我将我自己写好的Demo工程目录结构截图展示出来方便大家新建项目这张图图片清晰地将我的工程清晰地展示出来,先简单介绍下吧 ,项目主包是以com.cntv开始的 。在之...

weixin_29492649的博客 262

单工程搭建springmvc+spring+mybatis(maven,idea)

单工程搭建springmvc+spring+mybatis(maven,idea) 1.pom.xml <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.source>1.7</mav...

weixin_30414155的博客 97

Spring、SpringMVC与Mybatis整合工程的搭建

一、基础环境搭建 1. 1、 创建一个maven工程、在pom.xml 中引入项目依赖的jar包 ,下面是最终目录结构: pom.xml 代码如下: &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:sch...

sunshine的博客 225

spring+springMVC+Mybatis在maven工程的搭建总结

前期是一个一个单独的搭建,一步一步解决问题,现在利用一上午的时间进行集成的搭建。 1、搞清楚了单步的搭建,集成的搭建就很好理解,甚至自己可以稍微对原教程可以变通一下。 2、springmvc在前台,但是org.springframework.web.context.ContextLoaderListener可以通过配置来加载一些自己需要的bean,mybatis就是通过这种

Trend的博客 489

搭建Spring+SpringMVC+MyBatis工程

使用Maven搭建一个SSM工程: 1、工程预览:2、maven工程使用pom.xml导入相关jar包:如果不使用maven那么就将jar包下载好,直接放到lib中 首先要创建pom.xml:<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance

rui358的博客 426

Inteliij Idea 搭建Spring+SpringMVC+Mybatis工程 学习笔记

使用Maven构建Spring+SpringMVC+Mybitys工程 1.环境检查 2.Inteliij Idea工具准备 旗舰版 3.MySql 4.创建Web工程 1)新建工程 选择Maven,选择SDK版本,勾选骨架,选择maven-archetype-webapp骨架,next 设置地址和模块 配置Maven仓储,选用自带3.3.9 自己装的3.6.3报错了~ 勾选覆盖,选择自己设置的仓储设置,以及本地仓储路径 镜像是阿里的 <localR.

qq_20369621的博客 363

手把手带你实现Spring、SpringMVC与Mybatis整合工程的搭建

今天给大家带来的的SSM整合,在系统的学习完Spring +SpringMVC+Mybatis框架后,我们就可以开始整合SSM框架了,这里给大家介绍的是SSM_CRUD的demo项目整合,CRUD(create 创建、retrieve 查询、update 更新、delete 删除)也是SSM框架中最为常用的工程功能。 项目开源 https://github.com/AixsCode/SSM_

AixsCode 4396

如何搭建SSM(SpringMvc+mybatis+Spring)java web工程

No.1   首先将web工程结构建好 1.1.1 开发环境介绍  在这里我是采用的是mysql数据库    编译器版本采用的是jdk使用的是1.8  开发工具是使用的是eclipse Mars版本   web容器采用的是tomcat 版本是7.0版本    在这里我将我自己写好的Demo工程目录结构截图展示出来方便大家新建项目 这张图图片清晰地将我的工程清晰地展

Jason763的博客 1万+

【Spring+SpringMVC+MyBatis深入学习及搭建】10.MyBatis逆向工程

转载请注明出处:http://www.cnblogs.com/Joanna-Yan/p/6973266.html  前面讲到:Spring+SpringMVC+MyBatis深入学习及搭建(九)——MyBatis和Spring整合 使用官方网站的mapper自动生成工具mybatis-generator-core-1.3.2来生成po类和mapper映射文件。 1.什么是逆向工程 myba

剑翊乾坤 598
上一篇: rosjava入门
下一篇: 今日头条前端面试
RobotBing
博客等级 码龄10年 33粉丝 37原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值