ssm项目搭建

系统环境搭建

  1. Spring的jar包11个

    com.springsource.org.aopalliance-1.0.0.jar  //Aopi联盟的jar包遵循其规则
    com.springsource.org.aspectj.weaver-1.6.8.RELEASE.jar //面向切面编程
    spring-aop-5.0.1.RELEASEjar //实现aop
    spring-aspects-5.0.1.RELEASEjar //aspect整合的jar包
    spring-beans-5.0.1.RELEASEjar
    spring-context-5.0.1.RELEASEjar
    spring-core-5.0.1.RELEASEjar
    spring-expression-5.0.1.RELEASEjar
    spring-jcl-5.0.1.RELEASEjar
    spring-jdbc-5.0.1.RELEASEjar //访问数据库
    spring-tx-5.0.1.RELEASEjar  //事务
    
  2. SpringMVC的jar包

    spring-web-5.0.1.RELEASEjar
    spring-webmvc-5.0.1.RELEASEjar
    
  3. MyBatis的jar包1个

    mybatis-3.4.3.jar //核心jar包
    //依赖包12个
    
  4. MyBatis和Spring整合的jar包1个

    mybatis-spring-1.2.1.jar
    
  5. 数据库驱动jar包1个

    mysql-connector-java-5.1.7-bin.jar
    
  6. 数据源(bruid的jar包1个)

    druid-1.1.5.jar
    
  7. JSTL的jar包2个

    jstl-1.1.2.jar
    standard-1.1.2.jar
    

创建配置文件

  1. 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"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context.xsdhttp://www.springframework.org/schema/mvchttp://www.springframework.org/schema/mvc/spring-mvc.xsd"><!--注册组件扫描,扫描所有的handler包下的注册@Controller--><context:component-scan base-package="com.hrm.**.handler"/><!--mvc注解驱动,需要类型转换时候自动--><mvc:annotation-driven/><mvc:default-servlet-handler/>
</beans>
  1. spring-service.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"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context.xsd"><!-- 扫描@Service--><context:component-scan base-package="com.hrm.**.service"/></beans>
  1. spring-mybatis.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"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsd"><!--生成dao代理对象--><bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"><property name="basePackage" value="com.hrm.**.dao"/><property name="sqlSessionFactoryBeanName" value="mySqlSessionFactory"/></bean><!--注册SqlSessionFactory--><bean id="mySqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"><property name="dataSource" ref="MyDataSource"/><property name="configLocation" value="classpath:mybatis.xml"/></bean>
</beans>
  1. spring-ds.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"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context.xsd"><context:property-placeholder location="classpath:jdbc.properties"/><bean id="MyDataSource" class="com.alibaba.druid.pool.DruidDataSource"><property name="driverClassName" value="${jdbc.driver}"></property><property name="url" value="${jdbc.url}"></property><property name="username" value="${jdbc.username}"></property><property name="password" value="${jdbc.password}"></property></bean>
</beans>

jdbc.properties

jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql:///hrm
jdbc.username=root
jdbc.password=wqd123
  1. mybatis.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configurationPUBLIC "-//mybatis.org//DTD Config 3.0//EN""http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration><typeAliases><package name="com.hrm.commons.benas"/></typeAliases><!--注册映射文件--><mappers><!--<mapper resource="com/itheima/dao/IUserDao.xml"/>--><package name="com.hrm.**.dao"></package></mappers>
</configuration>
  1. spring-tx.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:tx="http://www.springframework.org/schema/tx"xmlns:aop="http://www.springframework.org/schema/aop"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx.xsdhttp://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop.xsd"><bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"><property name="dataSource" ref="MyDataSource"/></bean><tx:advice id="txAdvice" transaction-manager="txManager"><tx:attributes><tx:method name="add*" propagation="REQUIRED" isolation="DEFAULT"/><tx:method name="remove*" propagation="REQUIRED" isolation="DEFAULT"/><tx:method name="modify*" propagation="REQUIRED" isolation="DEFAULT"/><tx:method name="find*" propagation="REQUIRED" isolation="DEFAULT" read-only="true"/></tx:attributes></tx:advice><aop:config><aop:advisor advice-ref="txAdvice" pointcut="execution(* *..service.*.*(..))"/></aop:config>
</beans>

这些配置文件怎么才能运行:在WEB-INF下的web.xml中配置中央调度器
web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1"><display-name>hrm</display-name><servlet><servlet-name>springmvc</servlet-name><servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class><init-param><param-name>contextConfigLocation</param-name><param-value>classpath:spring-*.xml</param-value></init-param><load-on-startup>1</load-on-startup></servlet><servlet-mapping><servlet-name>springmvc</servlet-name><url-pattern>/</url-pattern>  <!--/会出现静态资源访问不到,3种解决办法--></servlet-mapping>			<!--最简单的一种就是springmvc.xml中配置--><!--<mvc:default-servlet-handler>--><!--注册字符过滤器-->
<filter><filter-name>CharacterEncodingFilter</filter-name><filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class><init-param><param-name>encoding</param-name><param-value>UTF-8</param-value></init-param><init-param><param-name>forceEncoding</param-name><param-value>true</param-value></init-param></filter><filter-mapping><filter-name>CharacterEncodingFilter</filter-name><url-pattern>/*</url-pattern></filter-mapping><welcome-file-list><welcome-file>index.html</welcome-file><welcome-file>index.htm</welcome-file><welcome-file>index.jsp</welcome-file><welcome-file>default.html</welcome-file><welcome-file>default.htm</welcome-file><welcome-file>default.jsp</welcome-file></welcome-file-list>
</web-app>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/557888.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【计算机网络】——习题解析:一个UDP用户数据的数据字段为8192字节,在数据链路层要使用以太网来传输,试问应当划分为几个IP数据报片?说明每一个IP数据报字段长度和片偏移字段的值

【计算机网络】——习题解析&#xff1a;一个UDP用户数据的数据字段为8192字节&#xff0c;在数据链路层要使用以太网来传输&#xff0c;试问应当划分为几个IP数据报片&#xff1f;说明每一个IP数据报字段长度和片偏移字段的值 答&#xff1a;6个数据字段的长度&#xff1a;前5…

java网络接口_java网络编程之识别示例 获取主机网络接口列表

importjava.net.*;importjava.util.Enumeration;publicclassInetAddressExample{publicstaticvoidmain(String[]args){//TODOAuto-generatedmethodstubtry{//获取主机网络接口列表EnumerationinterfaceListNetworkInterface.getNetworkInterfaces();//检测接口列表是否为空,即使…

网络协议,各层功能,各层协议

一、OSI七层模型 OSI七层协议模型主要是&#xff1a;应用层&#xff08;Application&#xff09;、表示层&#xff08;Presentation&#xff09;、会话层&#xff08;Session&#xff09;、传输层&#xff08;Transport&#xff09;、网络层&#xff08;Network&#xff09;、数…

vc2010 mysql5.7_VC2010利用MySQL++访问mysql. 及连接池示例

参加这个哥们的博客http://www.voidcn.com/article/p-mfnvxzca-cd.html 我的一个测试例子&#xff0c;用到了blob&#xff1b; #include #include #include #include #include using namespace mysqlpp; using namespace std; sql_create_3(sorttest,1,3,sql_int_unsigned,id,s…

java中下拉框select和单选按钮的回显操作

1.下拉框select的回显 <select name"departmentId" id"departmentId"><option value"0">请选择部门</option><c:forEach items"${departmentList }" var"department"><!-- 下拉框回显 -->&l…

fastdfs java token_fastdfs-client-java操作fastdfs

一、在https://github.com/happyfish100/fastdfs-client-java 下载客户端&#xff0c;解压后并执行ant命令&#xff0c;在E:\tools\libs\fastdfs\fastdfs-client-Java-master\src\build下会生成fastdfs_client.jar如图示二、mvn安装fastdfs_client.jar&#xff0c;在cmd中执行命…

idea编辑器中使用@Data注解无效解决办法

使用Data注解可以减少了以前的get和set等方法&#xff0c;但是在idea编辑器中不认识会在使用实体类元素时候找不到&#xff08;但是运行不会报错&#xff09; 所以可以添加插件

java spring 加载顺序_java – 如何执行spring配置类的加载顺序?

我正在一个多模块项目(maven)上使用spring-boot.每个模块都有自己的Configuration类.基本上我确实有如下的布局模块嵌入式(运行只调用SpringApplication.run())方法&#xff1a;ConfigurationEnableAutoConfigurationComponentScan("de.foobar.rootpackage")Import({…

@Mapper和@Repository的区别

Mapper和Repository的区别 1.相同点 Mapper和Repository都是作用在dao层接口&#xff0c;使得其生成代理对象bean&#xff0c;交给spring 容器管理 对于mybatis来说&#xff0c;都可以不用写mapper.xml文件 2.不同点 Mapper不需要配置扫描地址&#xff0c;可以单独使用&#x…

java xstream jar_Java库使用----xstream1.3.1

package com.xstream;import java.util.Map;/*** XStream可以自动生成相关的xml配置*/public class XstreamTest{private String moduleName;private Map env;public String getModuleName(){return moduleName;}public void setModuleName(String moduleName){this.moduleName…

在Spring Boot + Mybatis 中,使用@Repository失效

在Spring Boot Mybatis 中&#xff0c;使用Repository失效 在springboot 中&#xff0c;给mapper的接口上加上Repository&#xff0c;无法生成相应的bean,从而无法Autowired&#xff0c;这是因为spring扫描注解时&#xff0c;自动过滤掉了接口和抽象类&#xff0c;这种情况下可…

java中arg函数_main函数必须要带参数(String[] args)吗?

String[] args是main函数的形式参数,可以用来获取命令行用户输入进去的参数。java 本身不存在不带String args[]的main函数&#xff0c;java程序中去掉String args[]会出现错误。建个test类 在cmd中运行时输入java test a b c,并且在你的main函数里面加这段话&#xff1a;Syste…

git本地库(操作具体命令)

在任何盘符下创建本地仓库repository&#xff08;除git目录下&#xff09; 在项目目录创建新的本地仓库&#xff0c;并把项目里的所有文件全部添加、提交到本地仓库中去&#xff1a; $ git init #在当前的目录下创建一个新的空的本地仓库 Initialized empty Git repository…

用java做一个小游戏源代码_用java编写的小游戏源代码分析

用java编写的小游戏源代码分析1/5/2008人气&#xff1a;12951import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.util.*;public class GreedSnake implements KeyListener{JFrame mainFrame;Canvas paintCanvas;JLabel labelScore;SnakeModel snake…

idea右键项目没有git 【解决方法】

右键项目&#xff0c;没有git选项 解决方法&#xff1a; 进入settings,然后搜索version,按下图点击即可&#xff1a; over&#xff0c;解决&#xff1a;

java注解执行顺序_如何确保java中的注释执行顺序?

您可以使用Order注释确保自定义注释的顺序.例&#xff1a;第一个注释&#xff1a;Retention(RetentionPolicy.RUNTIME)Target(ElementType.METHOD)public interface CustomAnnotation {}AspectComponentOrder(value 1)public class CustomAnnotationInterceptor {Before("…

用java设计秒表_运用Java编写 秒表程序

import java.awt.*;import java.awt.event.*;import javax.swing.*;public class SecondJFrame extends JFrame implements ActionListener,FocusListener{ //响应单击、焦点事件private JTextField text;private JB…

GIT commit问题 No errors and 30 warnings found. Would you like to review them?

GIT commit问题 No errors and 30 warnings found. Would you like to review them?

java spring 条件注解_【Spring】Spring高级话题-条件注解-@Condition

进行本示例的演示&#xff0c;需要先配置好Maven和Spring哦、见:【Spring】基于IntelliJ IDEA搭建Maven分析通过profile&#xff0c;我们可以获得不同的profile&#xff0c;我们可以获得不同的Bean。Spring4提供了一个更通用的基于条件的Bean的创建&#xff0c;即使用Condition…

META-INF目录是干啥用的?

平时写的web项目打包成jar文件之后会发现里面不知道为啥多出了一个叫做META-INF的目录&#xff0c;点开之后发现里面还出现了一个manifest.mf文件。出于好奇我在网上找了找这个目录的用途&#xff0c;结果还是没有找到一个比较通俗的解释&#xff0c;我这种菜鸟对那种比较正规的…