Java框架_Spring5_day04_IOC(DBUtils)

泛微OA自定义post接口和路径(无侵入) 阅读详情

目录

五、基于注解的 IOC 配置

六、使用 Spring 的 IOC 实现账户的CRUD

6.1 使用 XML 配置 IOC

6.2 使用注解配置 IOC


五、基于注解的 IOC 配置

以下注解是用于创建对象的​,他们的作用就和在XML配置文件中编写一个<bean>标签实现的功能是一样的

(1)@Component:

        作用:用于把当前类对象存入spring容器中​

        属性:​ * value:用于指定bean的id。当我们不写时,它的默认值是当前类名,且首字母改小写。

(2)Spring中提供了@Component的衍生注解:

  • @Controller:用来修饰WEB层类(控制层)(springMVC延用了该注解)

  • @Service:用来修饰service层类(业务层)

  • @Repository:用来修饰DAO层类(持久层)

        以上三个注解他们的作用和属性与Component是一模一样。​ 他们三个是spring框架为我们提供明确的三层使用的注解,使我们的三层对象更加清晰。

以下注解是用于注入数据的,它们的作用就和在xml配置文件中的bean标签中写一个<property>标签的作用是一样的​ @Autowired: 基于spring

       作用:自动按照类型注入。只要容器中有唯一的一个bean对象类型和要注入的变量类型匹配,就可以注入成功。如果ioc容器中没有任何bean的类型和要注入的变量类型匹配,则报错。​ 如果Ioc容器中有多个类型匹配时:先按照类型匹配,如果不能匹配上,会按照属性的名称进行匹配​

       出现位置:​ 可以是变量上,也可以是set方法上​

       细节:在使用注解注入时,set方法就不是必须的了。​

@Qualifier: 配合@Autowired注解一起使用

       作用:在按照类型注入的基础之上再按照名称注入。​

       属性:​ value:用于指定注入bean的id。​

@Resource​ JSR-250标准(基于jdk)

       作用:直接按照bean的id名称注入。如果id属性不存在,可以再按照类型注入。它可以独立使用​

       属性:​ name:用于指定bean的id,如果指定name,只能按照bean的id注入,不能按照类型注入。​ 注意:

以上三个注入都只能注入其他bean类型的数据,而基本类型和String类型无法使用上述注解实现(使用@Value)。

以下注解是用于改变作用范围的,他们的作用就和在bean标签中使用scope属性实现的功能是一样的​

@Scope​

       作用:用于指定bean的作用范围​

       属性:​ value:指定范围的取值。

       常用取值:singleton prototype

AccountDaoImpl.java

package com.cpz.dao.impl;

import com.cpz.dao.AccountDao;
import org.springframework.stereotype.Repository;

@Repository(value = "accountDao")
public class AccountDaoImpl implements AccountDao {
    public void save() {
        System.out.println("执行AccountServiceImpl中的save方法....");
    }
}

AccountServiceImpl.java

@Service(value = "accountService")
@Scope(value = "singleton")
public class AccountServiceImpl implements AccountService {

    //@Autowired
    //@Qualifier(value = "accountDao")
    @Resource(name = "accountDao2")
    AccountDao accountDao;

    @Value(value = "xixi")
    String msg;

    public AccountServiceImpl(){
        System.out.println("构造方法...");
    }

    public void saveAccount() {
        System.out.println("执行AccountServiceImpl中的saveAccount方法...." + msg);
        accountDao.save();
    }
    @PostConstruct
    public void init(){
        System.out.println("初始化...");
    }
    @PreDestroy
    public void destroy(){
        System.out.println("销毁...");
    }
}

applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       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">

    <!--告知spring在创建容器时要扫描的包,配置所需要的标签不是在beans的约束中,而是一个名称为
        context名称空间和约束中-->
    <context:component-scan base-package="com.cpz"></context:component-scan>

</beans>

六、使用 Spring 的 IOC 实现账户的CRUD

6.1 使用 XML 配置 IOC

导入坐标,pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.cpz</groupId>
    <artifactId>spring_account_xmlioc</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>5.0.2.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>
        <dependency>
            <groupId>commons-dbutils</groupId>
            <artifactId>commons-dbutils</artifactId>
            <version>1.4</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.6</version>
        </dependency>
        <dependency>
            <groupId>c3p0</groupId>
            <artifactId>c3p0</artifactId>
            <version>0.9.1.2</version>
        </dependency>
    </dependencies>
</project>

applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       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">

    <!-- 使用import标签导入其他配置文件 -->
    <import resource="classpath:applicationContext-dao.xml"></import>
    <import resource="classpath:applicationContext-service.xml"></import>
    <import resource="classpath:applicationContext-dbutils.xml"></import>

</beans>

applicationContext-dao.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       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">


    <!--配置Dao对象-->
    <bean id="accountDao" class="com.cpz.dao.impl.AccountDaoImpl">
        <property name="queryRunner" ref="queryRunner"></property>
    </bean>

</beans>

applicationContext-service.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       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">

    <!-- 配置Service -->
    <bean id="accountService" class="com.cpz.service.impl.AccountServiceImpl">
        <property name="accountDao" ref="accountDao"></property>
    </bean>
</beans>

applicationContext-dbutils.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       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">

    <!-- 与jdbc.properties属性文件相关联 -->
    <context:property-placeholder location="classpath:jdbc.properties"></context:property-placeholder>

    <!--配置QueryRunner,设置prototype为多例,表示每次调用都获取一个新的连接对象-->
    <bean id="queryRunner" class="org.apache.commons.dbutils.QueryRunner" scope="prototype">
        <constructor-arg name="ds" ref="dataSource"></constructor-arg>
    </bean>
    <!-- 配置数据源 -->
    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
        <property name="driverClass" value="${jdbc.driverClass}"></property>
        <property name="jdbcUrl" value="${jdbc.jdbcUrl}"></property>
        <property name="user" value="${jdbc.user}"></property>
        <property name="password" value="${jdbc.password}"></property>
    </bean>
</beans>

jdbc.properties

jdbc.driverClass=com.mysql.jdbc.Driver
jdbc.jdbcUrl=jdbc:mysql:///spring
jdbc.user=root
jdbc.password=1234

AccountDao.java

package com.cpz.dao;

import com.cpz.domain.Account;

import java.util.List;

public interface AccountDao {

    public List<Account> findAll();

    public Account findById(Integer id);

    public void save(Account account);

    public void update(Account account);

    public void delete(Integer id);

}

AccountDaoImpl.java

package com.cpz.dao.impl;

import com.cpz.dao.AccountDao;
import com.cpz.domain.Account;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import org.springframework.stereotype.Repository;

import java.sql.SQLException;
import java.util.List;

public class AccountDaoImpl implements AccountDao {

    QueryRunner queryRunner;

    public void setQueryRunner(QueryRunner queryRunner) {
        this.queryRunner = queryRunner;
    }

    public List<Account> findAll() {
        List<Account> list = null;
        try {
            list = queryRunner.query("select * from account", new BeanListHandler<Account>(Account.class));
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return list;
    }

    public Account findById(Integer id) {
        List<Account> list = null;
        try {
            list = queryRunner.query("select * from account where id = ?",new BeanListHandler<Account>(Account.class),id);
            if (list == null && list.size() == 0){
                return null;
            }else if (list.size() > 1){
                new RuntimeException("查询结果大于一");
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return list.get(0);
    }

    public void save(Account account) {
        try {
            queryRunner.update("insert into account (name,money) values (?,?)",account.getName(),account.getMoney());
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    public void update(Account account) {
        try {
            queryRunner.update("update account set name = ?,money = ? where id = ?",account.getName(),account.getMoney(),account.getId());
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    public void delete(Integer id) {
        try {
            queryRunner.update("delete from account where id = ?",id);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}

AccountService.java

package com.cpz.service;

import com.cpz.domain.Account;

import java.util.List;

public interface AccountService {

    public List<Account> findAccountAll();

    public Account findAccountById(Integer id);

    public void saveAccount(Account account);

    public void updateAccount(Account account);

    public void deleteAccount(Integer id);

}

AccountServiceImpl.java

package com.cpz.service.impl;

import com.cpz.dao.AccountDao;
import com.cpz.domain.Account;
import com.cpz.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.annotation.Resource;
import java.util.List;

public class AccountServiceImpl implements AccountService {

    AccountDao accountDao;

    public void setAccountDao(AccountDao accountDao) {
        this.accountDao = accountDao;
    }

    public List<Account> findAccountAll() {
        List<Account> list = accountDao.findAll();
        return list;
    }

    public Account findAccountById(Integer id) {
        Account account = accountDao.findById(id);
        return account;
    }

    public void saveAccount(Account account) {
        accountDao.save(account);
    }

    public void updateAccount(Account account) {
        accountDao.update(account);
    }

    public void deleteAccount(Integer id) {
        accountDao.delete(id);
    }
}

SpringTest 测试类

package com.cpz.test;

import com.cpz.domain.Account;
import com.cpz.service.AccountService;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.List;

public class SpringTest {

    @Test
    public void findAll(){
        ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");
        AccountService accountService = ac.getBean("accountService", AccountService.class);
        List<Account> list = accountService.findAccountAll();
        for (Account account : list) {
            System.out.println(account);
        }
    }

    @Test
    public void findById(){
        ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");
        AccountService accountService = ac.getBean("accountService", AccountService.class);
        Account account = accountService.findAccountById(1);
        System.out.println(account);
    }

    @Test
    public void save(){
        ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");
        AccountService accountService = ac.getBean("accountService", AccountService.class);
        Account account = new Account();
        account.setName("ccc");
        account.setMoney(200f);
        accountService.saveAccount(account);
    }

    @Test
    public void update(){
        ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");
        AccountService accountService = ac.getBean("accountService", AccountService.class);
        Account account = accountService.findAccountById(3);
        account.setName("张三");
        accountService.updateAccount(account);
    }

    @Test
    public void delete(){
        ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");
        AccountService accountService = ac.getBean("accountService", AccountService.class);
        accountService.deleteAccount(3);
    }
}

6.2 使用注解配置 IOC

       这里使用的注解就是本文开头所讲的那些,更多的注解用法将在下一章详细阐述。

6.3 应用

今后企业开发的时候:一般配置文件(xml)+  注解混合使用

配置文件:

  • 第三方提供的对象(QueryRunner、C3P0),可以由配置文件XML完成

  • 自己创建的对象(Controller、Service、Dao、工具类Utils),可以由注解进行完成

【软考高项】【计算专题】- 3 - 进度类 - 双代号网络图 共需压缩 20 天。在双代号网络图中,工作一般使用箭线表示,任意一条箭线都需要占用时间、消耗资源,工作名称写在箭线的上方,而消耗的时间则写在箭线的下方或者工作后面。反映的是前后工作的交接点,节点中的编号可以任意编写,但应保证后续工作的节点比前面节点的编号大,即上图图中的1⃣️4⃣️ 即表示 B 活动和 D 活动间有依赖关系,D 活动的开始,依赖 B 活动的结束。B活动完成了一半, 各计划的实际支出为A活动6500元, B活动1000元, C活动280元, D。 阅读详情

相关推荐

ChatBI实战:如何用Vanna和WrenAI搭建企业级智能问数系统(附避坑指南)

本文详细介绍了如何利用Vanna和WrenAI搭建企业级智能问数系统(ChatBI),解决多源异构数据整合、语义理解准确率和系统性能安全等核心挑战。通过实战案例和优化策略,展示了这一组合方案在提升查询效率、实现业务自主分析和动态探索式分析方面的显著优势,特别适合企业级数据查询需求。

weixin_29047919的博客 400

java之学习记录 6 - 2 - Spring IOC介绍及应用(下)(DBUtils(IOC知识练习)、Spring注解开发及整合Junit)

六 DbUtils(IOC实战) 6.1 DbUtils是什么? DbUtils是Apache的一款用于简化Dao代码的工具类,它底层封装了JDBC技术。 核心对象 QueryRunner queryRunner = new QueryRunner(DataSource dataSource); 核心方法 int update(); 执行增、删、改语句 T query(); 执行查询语句 ResultSetHandler<T> 这是一个接口,主要作用是将数据

dear_zx的博客 272

Unity嵌套ScrollView滑动冲突解决方案:ExecuteEvents.Execute事件透传

在Unity UGUI中,竖向与横向ScrollView嵌套时出现滑动失效,本质是EventSystem事件分发机制的拦截限制。其原理在于PointerDown被外层捕获后,后续PointerMove默认不向下透传;ExecuteEvents.Execute提供了一条绕过常规冒泡流程的官方事件旁路,支持低延迟、方向自适应的精准透传。该技术具备高兼容性与零侵入特性,广泛应用于电商商品页、内容流卡片组、多级导航等需‘列表中嵌套轮播/标签’的真实场景,是解决UGUI嵌套滚动问题的核心工程实践方案。

weixin_33164198的博客 632

Spring-学习笔记06【spring_day02资料_dbutils】

Spring-学习笔记06【spring_day02资料_dbutils】

upward 541

从专利库到Zemax:一个6mm定焦镜头从零到交付的完整设计流程(含CodeV转换技巧)

本文详细介绍了6mm定焦镜头从专利库检索到最终交付的全流程设计,重点解析了CodeV与Zemax工具链的无缝衔接技巧。通过实际案例展示规格定义、专利筛选、结构适配、非球面优化等关键步骤,帮助光学设计工程师提升设计效率和制造良率。特别包含CodeV转换Zemax的实用技巧,适用于机器视觉和安防镜头开发。

weixin_42561040的博客 161

ScottPlot vs LiveCharts:WPF图表库性能对比与MVVM适配方案

本文深度对比了WPF图表库ScottPlot与LiveCharts在性能与MVVM架构适配上的表现。通过十万级数据点的基准测试,ScottPlot在渲染速度与内存占用上优势显著。文章重点探讨了两种库在MVVM模式下的集成方案,为开发者根据项目需求(如实时监控或快速原型)进行技术选型提供了实战指导。

lll78的博客 245

Spring--04基于XML的IoC配置实现账户的CRUD

项目说明 此项目使用mysql作为数据库 使用dbutils作为数据封装工具类 使用c3p0作为数据源 整合了spring和junit 实现对账户的添加,查找,更新,删除。 注意 使用注解配置IoC时,bean.xml需要更换不同的约束。 搭建开发环境 数据库表:account 新建maven工程,编写pom文件 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0

Ur_Eyes_的博客 173

NOAA气象数据下载攻略

各方搜寻气象数据下载途径,发现网上最多的就是从NOAA下载,但是中途有尝试过很多次都没有下载到,每次都是显示不可用,今天终于下载成功了,特此记录。 首先我是从这个网址进入的:National Centers for Environmental Information (NCEI) formerly known as National Climatic Data Center (NCDC) | NCEI offers access to the most significant archives of oc

lianqian66的博客 3万+

Spring--10基于XML的AOP配置实现事务控制

项目需求 利用事务管理器和AOP配置,实现事务控制 基于XML的IoC配置 项目说明 整合spring和junit 数据源采用c3p0 利用DBUtils对jdbc简单封装 DBUtils百科介绍 Commons DbUtils是Apache组织提供的一个对JDBC进行简单封装的开源工具类库,使用它能够简化JDBC应用程序的开发,同时也不会影响程序的性能。 [1] AspectJ百科介绍 AspectJ是一个面向切面的框架,它扩展了Java语言。AspectJ定义了AOP语法,它有一个专门的编

Ur_Eyes_的博客 236

统信UOS/麒麟Kylin OS下利用pyenv实现Python多版本开发环境搭建指南

本文详细介绍了在统信UOS和麒麟Kylin OS国产操作系统下使用pyenv搭建Python多版本开发环境的完整指南。从系统环境准备、pyenv定制安装到Python版本编译实战,提供了针对国产CPU架构的特殊优化方案和常见问题解决方法,帮助开发者高效管理不同Python版本需求。

sea99的博客 1051

机器学习的低代码与无代码平台:便捷入门之路

机器学习领域正涌现出大量低代码和无代码平台,使非技术人员也能轻松应用AI技术。低代码平台(如PyCaret、H2O AutoML)需少量编程但灵活性强,而无代码工具(如Google Cloud AutoML、Teachable Machine)则完全无需编程基础。这些平台覆盖图像识别、文本处理、业务预测等多种场景,适合快速部署简单项目。但专业人士仍需注意,这些工具无法替代复杂场景下的定制化开发。随着技术进步,低门槛AI工具正在改变各行业的创新方式。

2501_90323865的博客 154

Spring--11基于注解的AOP配置实现事务控制

项目需求 利用事务管理器和AOP配置,实现事务控制 基于注解的IoC配置 项目说明 整合spring和junit 数据源采用c3p0 利用DBUtils对jdbc简单封装 新建Account实体类 package com.cncs.domain; import java.io.Serializable; public class Account implements Serializable { private int id; private String name;

Ur_Eyes_的博客 228

Mediatek NeuroPilot Yolov8量化

【代码】Mediatek NeuroPilot Yolov8模型转化。

sdrgtywretyeruet的专栏 346

Java框架_SpringMVC_day03_注解开发

目录 四、SpringMVC 中的常用注解 4.1 @RequestParam注解:请求参数,用于指定参数名称 4.1.1 anno.jsp 4.1.2 AnnoController.java 4.2 @RequestBody注解:请求体,用于将json数据封装成java类 4.2.1 anno.jsp 4.2.2 Controller 4.3 @PathVariable注解:用于...

cpz 405

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

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

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

Java框架_Maven_day01

目录 一、 Maven的相关概念 1.1 Maven介绍 1.1.1 什么是Maven 1.1.2 Maven的作用 1.1.3 Maven的好处 1.2 Maven仓库和坐标 1.2.1 Maven的仓库 1.2.2 Maven的坐标 二、Maven 的常用命令 2.1 clean命令 2.2 compile 命令 2.3 test 命令 2.4 package ...

cpz 383

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

Java框架_Mybatis_day01_概述/入门案例

目录 一、框架的概述 1.1 常见的JavaEE开发框架 1)解决数据的持久化问题的框架 2)解决 WEB层问题的 MVC 框架 3)解决技术整合问题的框架 1.2 总结 二、Mybatis的概述 2.1 对JDBC的回顾 JDBC缺陷总结: 2.2 Mybatis的概述 2.3 ORM思想简介 三、Mybatis框架入门案例 3.1 导入Maven依赖 3.2 创建数...

cpz 368

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

Java框架_SpringMVC_day01_概念和入门

目录 一、SpringMVC 的基本概念 1.1 关于三层架构和 MVC 1.1.1 三层架构 1.1.2 MVC 1.2 SpringMVC 的概述 1.2.1 SpringMVC 是什么 1.2.2 SpringMVC 的优势 1.2.3 SpringMVC和Struts2的优劣分析 二、SpringMVC 的入门 2.1 导入依赖坐标 2.2 配置 web.xml ...

cpz 354

Java框架_Spring5_day07_AOP(面向切面编程)

目录 九、Spring 中的 AOP 9.1 AOP 的细节 9.1.1 AOP 的相关术语 9.2 Spring 的 AOP 配置 9.2.1 applicationContext.xml 9.2.2 切入点表达式的写法 9.2.3 配置文件的修改 9.3 Spring AOP 的五种通知类型(使用XML) 9.3.1 Logger.java 9.3.2 applicatio...

cpz 318

Java框架_Maven_day02

目录 五、使用 Maven 搭建 WEB 项目 5.1 需求 5.2 代码实现 5.2.1 创建数据库test,建表 5.2.2 依赖管理 5.2.3 创建 JavaBean(Customer.java) 5.2.4 在 webapp 下创建 index.jsp 页面 5.2.5 在 webapp 下创建 /WEB-INF/web.xml 文件 5.2.6 在 resource ...

cpz 313

Java框架_Mybatis_day06_多表关联之一对一、一对多查询

目录 十、Mybatis 多表关联查询之一对多关系 10.1 创建账户表,添加数据 10.2 查询所有账户 10.3 一对一查询,查询账号同时关联用户(方案一) 10.4一对一查询,查询账号同时关联用户(方案二) 10.5 一对多查询,查询用户同时查询账号的集合 十、Mybatis 多表关联查询之一对多关系 10.1 创建账户表,添加数据 create table `acc...

cpz 312

Java框架_Spring5_day09_事务控制

十一、Spring 中的事务控制 11.1 Spring 事务控制的API 11.1.1 PlatformTransactionManager 此接口是spring的事务管理器,它里面提供了我们常用的操作事务的方法,如下图: 我们在开发中都是使用它的实现类: org.springframework.jdbc.datasource.DataSourceTransactio...

cpz 306

Java框架_Mybatis_day07_多表查询之多对多查询

目录 十一、Mybatis 多表查询之多对多查询 11.1 准备工作 11.1.1 角色表 11.1.2 Role.java 11.2多对多查询,查询角色同时关联用户 11.3多对多查询,查询用户同时关联角色 十一、Mybatis 多表查询之多对多查询 11.1 准备工作 这里我们新建一个角色表(role),并且创建 Role.java 、RoleDao....

cpz 282

Java框架_SpringMVC_day05_文件上传

目录 六、SpringMVC 实现文件上传 6.1 文件上传的必要前提 6.2 SpringMVC 传统方式的文件上传 6.2.1 数据准备 6.2.2 普通文件上传 6.2.3 SpringMVC 方式上传文件 6.3 SpringMVC 跨服务器方式的文件上传 6.3.1 分服务器存储的目的 6.3.2 准备两个 tomcat 服务器(创建图片服务器) 6.3.3 文件上传...

cpz 280

Java框架_SSM_day01_SSM的初次整合

目录 一、SSM整合步骤 1.1 整合步骤概述 1.1.1 整合思路 1.1.2 整合步骤 1.2 开发准备 1.2.1 导入 jar 包 1.2.2 创建实体类 1.2.3 创建 Dao 1.2.4 创建 Service 1.2.5 创建 Controller 1.3 搭建 Spring 的环境 1.3.1 applicationContext.xml 1.3.2 lo...

cpz 276

Java框架_Spring5_day01_Spring概述、耦合、IOC

目录 一、Spring 概述 1.1 Spring 是什么 1.2 Spring 的发展历程 1.3 Spring 的优势 1.4 Spring 的体系结构 二、IoC 的概念和作用 2.1 程序的耦合和解耦 2.2 解决程序耦合的思路一:反射 2.3 解决程序耦合的思路二:工厂模式 2.4 控制反转 - Inversion Of Control 一、Spring 概述 1...

cpz 276

Java框架_Mybatis_day04_配置文件/连接池/事务

目录 六、sqlMapConfig.xml 配置文件的深入研究 6.1 properties(属性) 6.2 typeAliases(类型别名) 6.3 mappers(映射器) 七、Mybatis 连接池 7.1 连接池的特点 7.2 连接池的分类 7.3 总结 八、Mybatis 中的事务 8.1 概念 8.2 事务的特性 8.3 不考虑隔离性会产生的问题 8.4 解...

cpz 272
上一篇: Java高级_多线程_day03_等待唤醒
下一篇: Java框架_Spring5_day05_IOC(注解)
chipeize
博客等级 码龄10年 23粉丝 80原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值