要做的 认识 的spring的是 :

====== 进行 xml 或 全注解 的通用 的 实验 =========

小需求 : 实现账户的 CRUD 操作 ========

技术要求

使用 全注解 开发

使用 spring 的 IoC 实现对象的管理

使用 DBAssit 作为持久层解决方案 使用 c3p0 数据源

回顾 在前一篇里 我们已经对于spring 的 的基本面的 认识 :

spring 框架所拥有的生态 : 有 7个 :ioc aop 事务 测试 集成 模板 源码学习
提供了 后端3层 的 解决方案 :

1: 表现层(控制层) springMVC
2: 持久层 SpringDate /或者还有封装jdbc 操作的模板
3: 与spring 的业务层

最新的版本迭代 是Spring5
spring 的2个core :IOC 与 AOP
一个重要作用 : 整合 其他的开源框架

他的核心 ioc 所实现的原理 :

依赖反转 将创建 对象  托付  给spring进行管理 交给spring 来做,----------让 spring  给代理了  --------- 而 spring是的ioc 的实现方式 也有 他的 代理方式-------- 动态代理  -------动态代理 2种 的实现:java jdk 基于接口 与  cglib  基于 父类 与 子实现类 --------- 都是要 基于反射  ---------- 而反射:需要java编写程序的代码文件------- 3个获取  ------加载类加载器  。。。。。

注解+ xml 配置 : Spring 开发的时候

第三方jar 包 用的是xml 实际中 纯 xml 配置 已经很少在用

基于xml 的注解 : 作用 于 crud 的增删改查 :

<?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/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:jdbcConfig.properties"></context:property-placeholder><!--   包扫描  --><context:component-scan base-package="com.fhw"></context:component-scan><!--  配置 sercice -->
<bean id="accountServiceI" class="com.fhw.service.impl.AccountServiceImpl"><!-- 注入dao --><property name="dao" ref="accountDao"></property>
</bean><!--  配置 dao --><bean id="accountDao" class="com.fhw.dao.impl.AccountImpl"><!--  注入 QueryRunner --><property name="query" ref="queryRunner"></property></bean><!--  配置 QueryRunner --><bean id="queryRunner" class="org.apache.commons.dbutils.QueryRunner"><constructor-arg name="ds" ref="dataSource"></constructor-arg></bean><!--<bean id="" class=""></bean>--><!--配置数据源的 --><bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"><property name="driverClass" value="${jdbc.driver}"></property><property name="jdbcUrl" value="${jdbc.url}"></property><property name="user" value="${jdbc.username}"></property><property name="password" value="${jdbc.password}"></property></bean></beans>

3 同样可以 完成 CRUD 的操作 :

.1 需求和技术要求
1.1.1 需求
实现账户的 CRUD 操作
1.1.2 技术要求
使用 spring 的 IoC 实现对象的管理 使用 DBAssit 作为持久层解决方案 使用 c3p0 数据源

测试

import com.fhw.pojo.Account;
import com.fhw.service.IAccountService;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;import java.util.List;public class AccountTest {@Testpublic void testFindAll(){
//     获取 容器ApplicationContext ac=new ClassPathXmlApplicationContext("applicationContext.xml");
//IAccountService accountService = ac.getBean("accountServiceI", IAccountService.class);List<Account> allAccount = accountService.findAllAccount();for (Account account : allAccount) {System.out.println(account);}}

在注入的 时候 写 的业务类 常用 是 set 的

public class AccountImpl implements IAccountDao {private QueryRunner query;//用apache 的工具类 来进行public void setQuery(QueryRunner query) {this.query = query;}
public class AccountServiceImpl implements IAccountService {private IAccountDao dao =new AccountImpl();public void setDao(IAccountDao dao) {this.dao = dao;}
测试图 =======

html 做表现 的 xml 做配置

后面的注解开发就会 : 常用 @Autowired 就不用set 了

纯注解的开发的 在springBoot 里比较常用 或 自定义 的类

数据源 的
都要实现的额接口 都是 实现 DataSource 接口 都是 使用getConnection 对象
c3p0 dirud
dbcp :Tomcat 内置的

c3p0 的使用 :

关闭数据库 归还的 到数据库连接池POOLED 里

c3p0,Druid 的 spring 集成 的使用 的 :

基于注解的 IOC 配置 :

都是减低程序之间的耦合 : 使用的是依赖反转的思想 :
入门的操作 :
3个注解 :
@Compont :只加这个注解 : Bean 的id 默认 是该类名称的 首字母小写
---- 使用 value 属性 来指定Bean的id 名称 就是你的自定义
使用位置 : 实现类的作用 : 让spring 反射 创建该类的实
@Autowired +@Qualifier (id)
在@ @Compont 是如何 然Spring 的识别的 就要
要告知 spring 在那些包 及子包 下
配置组件扫描 :

IOC :纯注解 ‘: 不用xml 了 : 用 注解来实现 :
一旦使用注解之后 就 不用 再 需要该 类 的 set方法 了


纯注解的开发的 在springBoot 里比较常用 :

所用的还是 ; CURD 的 增删改查 的

在注解 应用的 时候 先来认识 一下 : : 这些 各种的注解 是 如何 代替 xml 的 :

实现 定义bean 方面的 注解 :

@Component 相当于在 xml 中配置一个 bean。

value:指定 bean 的 id。不指定 value 属性,默认 bean 的 id 是当前类的类名 的首字母小写。

下来的是3层的 “ bean” 注解
@Controller ===== 控制层 的
@Service ===== 业务层 的
@Repository ===== 持久层 的
以上的注解 一加 之后 就会 出现小豆豆 Bean 的图形了

比如到最后 纯注解的 的这张图 :

使用3层的时候 注解的 时候 : 需要一的包扫面 ,这时候 还需要 xml 得来搭配的 : 在接下来的经理种将会 组不到 摘除 xml 相关的

问题 那些坑 bug 有图 有真相;,

相同且 无法分辩:

在这里插入代码片
接着会用到的是 :
会用到的 注入的 的 注解  @Autowired 自动注入 ==
@Qualifier 这个 用的少 :
单一的匹配,不安全,应该是类型+id名字 双重进行匹配
<!-- DI注解解析器 --><context:annotation-config/>Autowired的特点:首先按照类型去找,然后再按字段的名字(xml中的id属性)去找,两者都找不到就报错。匹配上就会注入进去。属性名字相同,xml中的id属性也相同: Bean name 'employ1' is already used in this <beans> element属性名字与xml中的id属性不相同,expected single matching bean but found 2: employ1,employ2单一的匹配,不安全,应该是类型+id名字 双重进行匹配@Autowired:如果使用单一个注解的话  一定要使用 DI注解解析器。@Qualifier("employ1")//用的很少  除非同一种类型的bean有多种定义的时候才会用的到--通过id去取@Autowired//根据类型找@Qualifier(value="mysqlDataSourceBean")//在根据名字找//相同类型的bean有多个  但是bean的id不同  <bean id="mysqlDataSourceBean" class="com.bean.MysqlDriveManagerDataSource"/><bean id="oracleDataSourceBean" class="com.bean.OracleDriveManagerDataSource"/>
---------------------
原文:https://blog.csdn.net/m0_37871296/article/details/88778932 

余下的 这些注解 :

@Resource

作用: 直接按照 Bean 的 id 注入。它也只能注入其他 bean 类型。 属性: name:指定 bean 的 id。

@Value

作用: 注入基本数据类型和 String 类型数据的 属性: value:用于指定值
2.3.3 用于改变作用范围的:
相当于:

@Scope

作用: 指定 bean 的作用范围。 属性: value:指定范围的值。 取值:singleton prototype request session globalsession

和生命周期相关的:(了解)

相当于:

@PostConstruct

作用: 用于指定初始化方法。

@PreDestroy

/*
*  回顾一下  : xml 配置的注意
*  <bean id="accountService" class="com.itheima.service.impl.AccountServiceImpl"*        scope=""  init-method="" destroy-method="">*      <property name=""  value="" | ref=""></property>*  </bean>*   ***** 注解的annotation的 里 要做是*      注解与xml  异曲同工  的   还是 作用与 bean 的*      这些  注解   bean 的 注入 spring 日容器 里*       @Component 只一个 总的注解*       -- 分别有 对应3层的注解 : 注入的 3 层区域的注解*          @Controller    控制层*          @service   : 业务层*          @Repository : 持久层*     具体注入的*     ============   bean类 引用数据的*** 注入***  注解  ===================*     @Autowired  :  自动注入  相当于 xml   的  property*       确定  id 的 唯一 就会注入*     但有多个类型 的时候*     ****** 位置上 : 变量 方法 上*         ***** 细节 : 除了 set 方法 还有替他的*     @Qualifier : 以名称注入 配合 Autowired 的 使用*       @Qualifier + @Autowired   来使用 的*    在入参的时候  可以使用 :*    @Resource  直接的注入 :*      ===============  @Value 基本数据  与   字符串的 *** 注入*** 使用的注解  ===============*   @Value  基本数据  与   字符串的注入 使用的是  value*     ===============   @Scope 改变作用域的*** 注入*** 使用的注解  ===============*        取值 : singleton   与  prototype*        ===============   @ 生命周期*** 注入*** 使用的注解  ===============*        PostConstruct : 初始化*        preDestroy  销毁***
*   */@Value("user")private String  username;//   private IAccountDao accountDao=new AccountDaoImpl();
@Autowired()//会 自动的找到 子实现类 进行注解  :
//@Resource(name = "Autowired_qualifier_noSpringNojdk9")//jdk9 已经不再支持来了private IAccountDao accountDao;
@PostConstructpublic void init() {System.out.println("accountService 初始化执行了 ......"); }
@PreDestroypublic void destrory() {System.out.println("accountService 销毁 前的  方法执行了 ......"); }public void saveAccount() {System.out.println("accountService执行了 ....");System.out.println("\"Value注解 注入的是是 前提是要有<context:property-placeholder location=\\\"classpath:jdbcConfig.properties"+username);
}

我们一案例来进行一个 curd 增删改查 的 账户操作 为 原型 ====

====== 进行 全注解 的通用 的 实验 =========

小需求 : 实现账户的 CRUD 操作 ========

技术要求

使用 全注解 开发

使用 spring 的 IoC 实现对象的管理

使用 DBAssit 作为持久层解决方案 使用 c3p0 数据源

pom
<?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.fhw</groupId><artifactId>springboot_all_annotation_01</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>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><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.10</version></dependency></dependencies></project>
账户类 : pojo【 实体类 】 实现序列化接口 implements Serializable
package com.fhw.pojo;import java.io.Serializable;public class Account implements Serializable{
private Integer id;
private String name;
private Float money;get ..... set ....
}
service 层 接口与 实现类 :
package com.fhw.service;import com.fhw.pojo.Account;import java.util.List;/*** 账户业务层的接口*/
public interface IAccountService {/*** 模拟保存账户*/void saveAccount(Account account);/*** 查询 所有* @param* @return*/List<Account> findAllAccount();/***  根据id  查询* @param id* @return*/Account findById(Integer id);/***  删除* @param id*/int deleteAccount (Integer id);/*** 更新* @param account*/void updateAccount(Account account);
}

service层 的 实现类 :

package com.fhw.service.impl;import com.fhw.dao.IAccountDao;
import com.fhw.pojo.Account;
import com.fhw.service.IAccountService;
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 java.util.List;/*** 账户的业务层实现类*/
//@Component("accountServiceComponent")//  @Component 只一个 总的注解
@Service("accountService")
//@Scope("prototype")
public class AccountServiceImpl implements IAccountService {@Autowired()private IAccountDao dao;/*** 模拟保存账户*/public void saveAccount(Account account ) {dao.saveAccount(account);}/*** 查询 所有* @param* @return*/public List<Account> findAllAccount() {return dao.findAllAccount();}/***  根据id  查询* @param id* @return*/public Account findById(Integer id) {return dao.findById(id);}/***  删除* @param id*/public int deleteAccount(Integer id) {return dao.deleteAccount(id);}/*** 更新* @param account*/public void updateAccount(Account account) {dao.updateAccount(account);}
}

持久层 的接口与实现类 :

package com.fhw.dao;import com.fhw.pojo.Account;import java.util.List;/*** 账户的持久层接口*/
public interface IAccountDao {/*** 模拟保存账户*/void saveAccount(Account account);/*** 查询 所有* @param* @return*/List<Account> findAllAccount();/***  根据id  查询* @param id* @return*/Account findById(Integer id);/***  删除* @param id*/int deleteAccount (Integer id);/*** 更新* @param account*/void updateAccount(Account account);
}
持久层 的 接口 实现类
package com.fhw.dao;import com.fhw.pojo.Account;import java.util.List;/*** 账户的持久层接口*/
public interface IAccountDao {/*** 模拟保存账户*/void saveAccount(Account account);/*** 查询 所有* @param* @return*/List<Account> findAllAccount();/***  根据id  查询* @param id* @return*/Account findById(Integer id);/***  删除* @param id*/int deleteAccount (Integer id);/*** 更新* @param account*/void updateAccount(Account account);
}

持久层 的 实现类

持久层 用的是 :

package com.fhw.dao.impl;import com.fhw.dao.IAccountDao;
import com.fhw.pojo.Account;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;import java.sql.SQLException;
import java.util.List;/*** 账户的持久层实现类*/
@Repository("accountDao")
public class AccountDaoImpl implements IAccountDao {@Autowired()private QueryRunner query;/*** 模拟保存账户*/public void saveAccount(Account account) {try {query.update("insert into account( name money ) values( ?,?)",account.getName(),account.getMoney());} catch (Exception e) {throw new RuntimeException(e);}}/*** 查询 所有* @param* @return*/public List<Account> findAllAccount() {try {return query.query("select * from account",new BeanListHandler<Account>(Account.class));} catch (Exception e) {throw new  RuntimeException(e);}}/***  根据id  查询w* @param id* @return*/public Account findById(Integer id) {try {return query.query("select * from account where id = ? ",new BeanHandler<Account>(Account.class),id);} catch (Exception e) {throw new  RuntimeException(e);}}/***  删除* @param id*/public int deleteAccount(Integer id) {try {return query.update("delete from account where id = ? ",id);} catch (Exception e) {throw new RuntimeException(e);}}/*** 更新* @param account*/public void updateAccount(Account account) {try {query.update("update account set name = ? ,money = ? where id = ?",account.getName(),account.getMoney(),account.getId());} catch (Exception e) {throw new RuntimeException(e);}}}

配置类 的 使用

父类 的 配置类 :

package com.fhw.config;import org.springframework.context.annotation.*;/*
* 该类的是一个配置类
*@Configuration : 用于指定是一个配置类
* @ComponentScan : 用于 指定要扫描 的包 底层还是 数组 的实现
* @Bean 是 在执行方法后的结果 一Bean的方式 来 注入到IOC 里
* ------  不指定属性的时候   就是该方法的 名称
* @import : 作用于其他 的 配置类*  */
//@Configuration("springConfiguration")
//不写的时候 就要在 AnnotationConfigApplicationContext(SpringConfiguration.class);
//@Configuration
@ComponentScan( "com.fhw")
@Import(DataConfig.class)
@PropertySource("classpath:com/fhw/jdbcConfig.properties")
public class SpringConfiguration {
}

子的 配置类 :

package com.fhw.config;import com.mchange.v2.c3p0.ComboPooledDataSource;
import org.apache.commons.dbutils.QueryRunner;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;import javax.sql.DataSource;
import java.beans.PropertyVetoException;/*** spring 配置类 的 连接数据库*/
//@Configuration
public class DataConfig {@Value("${jdbc.driver}")private String Driver;@Value("${jdbc.url}")private String JdbcUrl;@Value("${jdbc.username}")private String User;@Value("${jdbc.password}")private String Password ;/*** 创建 QueryRunner 对象* @param dataSource* @return*///  javax.sql.DataSource;@Bean("runner")//如果该方法有参数  回去容器里找  , 查找 原理  与 Autowired 一样 的public QueryRunner createQueryRunner(DataSource dataSource){return new QueryRunner( dataSource);}@Bean("dataSource")public  DataSource createDataSource(){try {ComboPooledDataSource ds = new ComboPooledDataSource();ds.setDriverClass(Driver);ds.setJdbcUrl(JdbcUrl);ds.setUser(User);ds.setPassword(Password);return ds;} catch (PropertyVetoException e) {throw new RuntimeException(e);}}
}
properties 配置文件 :
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/spring_c3p0_test001
jdbc.username=root
jdbc.password=root

测试类

package com.fhw.test;import com.fhw.config.SpringConfiguration;
import com.fhw.pojo.Account;
import com.fhw.service.IAccountService;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;import java.util.List;public class AccountTest {@Testpublic void testFindAll(){ApplicationContext ac= new AnnotationConfigApplicationContext(SpringConfiguration.class);//IAccountService accountService = ac.getBean("accountService", IAccountService.class);List<Account> allAccount = accountService.findAllAccount();for (Account account : allAccount) {System.out.println(account);}}@Testpublic void testSave(){
//     获取 容器ApplicationContext ac= new AnnotationConfigApplicationContext(SpringConfiguration.class);
//IAccountService accountService = ac.getBean("accountService", IAccountService.class);Account account = new Account();account.setName("fhwwww");account.setMoney(2500f);accountService.saveAccount(account);}@Testpublic void testFindById(){
//        获取 容器ApplicationContext ac= new AnnotationConfigApplicationContext(SpringConfiguration.class);
//IAccountService accountService = ac.getBean("accountService", IAccountService.class);
//       要跟新 的那条信息} @Testpublic void testUpdate(){
//     获取 容器ApplicationContext ac= new AnnotationConfigApplicationContext(SpringConfiguration.class);
//IAccountService accountService = ac.getBean("accountService", IAccountService.class);
//       要跟新 的那条信息Account account4= accountService.findById(5);account4.setName("f001");account4.setMoney(22222f);accountService.updateAccount(account4);} @Testpublic void testDelete(){
//     获取 容器ApplicationContext ac= new AnnotationConfigApplicationContext(SpringConfiguration.class);
//IAccountService accountService = ac.getBean("accountService", IAccountService.class);
//        Account account4 = accountService.findById(4);accountService.deleteAccount(5);}}

有了案例的加持 ======= 一起 回顾 这些注解 的

图解 -这些 注解的 总结 : ===============

这是扫描 包 主机的 底层的实现 :================

这是 @Bean ======= 注解的的底层实现

@Bean 在引入数据源的 注解 :

引入之前 :

引入之后 : 的对照 可以参考的是 : 子配置类 : DataConfig

配置类的注解 与源码: @Configuration


使用的 注解 : 定义 配置注解的的类 @Configuration

要么写在AnnotionConfigApplicationContext的参数里

要么 在该 配置类 使用 @Configuration

子配置类 使用注解 @Import (类名.class)

最总 回到运行终于测试 结果

spring与 junit 的这从一开始 就是这样 的 套路 :

首先我们要分析的 是 : 作为专项的测试 人员 : 要应有的专项 :

在团队 的开发中的 工作的 业务 也 要 像 我们认识到的 这款框架一样 :=== 解耦合


现在 想要期望的是 : 将原本不能 加载 IOC 容器 的 换做一个 可以执行的

====== 加的额是 Spring 的依赖的坐标 :

<dependency><groupId>org.springframework</groupId><artifactId>spring-test</artifactId><version>5.0.2.RELEASE</version></dependency>

用junit 的@

告知spring 运行器IOC 是基于 XML还是 注解的

@ Configuration

location : 指定 的是 xml 文件的 加上 classPath:位置 就 标识在类路径下

classes :指定注解所在位置 代表用注解 创建

spring5.x 的时候 要求Junit 的版本是4.12 以上

<dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.12</version></dependency>

#### 不然这里就会 出错 :
/* 如何确保 这些 全部都能 执行 增删改查 都能执行 先执行 加一条数据 就好多了 */

package com.fhw.test;import com.fhw.config.SpringConfiguration;
import com.fhw.pojo.Account;
import com.fhw.service.IAccountService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/*   @ Configuration  dde
*   location : 指定 的是  xml 文件的 加上classPath:位置 就 标识在类路径下
*    classes :指定注解所在位置 代表用注解 创建
*    spring5.x 的时候 要求Junit 的版本是4.12 以上
*
*   */
import java.util.List;
@RunWith(SpringJUnit4ClassRunner.class)
//获取 容器  ApplicationContext ac= new AnnotationConfigApplicationContext(SpringConfiguration.class);
@ContextConfiguration(classes = SpringConfiguration.class)
public class AccountTest {//注入容器  IAccountService accountService = ac.getBean("accountService", IAccountService.class)
/* 如何确保  这些  全部都能 执行    增删改查 都能执行      先执行  加一条数据   就好多了    */@Autowiredprivate IAccountService as = null;@Testpublic void testFindAll() {//3.执行方法List<Account> accounts = as.findAllAccount();for(Account account : accounts){System.out.println(account);} }@Testpublic void testFindOne() {//3.执行方法Account account = as.findAccountById(1);System.out.println(account);}/*  先执行  加一条数据   就好多了   */@Testpublic void testSave() {Account account = new Account();account.setName("test anno");account.setMoney(12345f);//3.执行方法as.saveAccount(account);}@Testpublic void testUpdate() {//3.执行方法Account account = as.findAccountById(9);account.setMoney(23456f);as.updateAccount(account);}@Testpublic void testDelete() {//3.执行方法as.deleteAccount(7);}
}

======== 最后圆满的答案 ========

spring 整合 xml junit完成 的

Spring 第二篇 注解+ xml 配置 与 纯注解开发 与集成 junit测试相关推荐

  1. Spring装配Bean---使用xml配置

    声明Bean Spring配置文件的根元素是<beans>. 在<beans>元素内,你可以放所有的Spring配置信息,包括<bean>元素的声明. 除了Bean ...

  2. Spring Aop实例之xml配置

    上篇博文<3幅图让你了解Spring AOP>中介绍了aop通知类型,AOP的配置方式有2种方式:xml配置和AspectJ注解方式.今天我们就来实践一下xml配置方式. 我采用的jdk代 ...

  3. 在eclipse中关于Spring和Hibernate 的XML配置如何提示类的包路径的办法

    转载自  在eclipse中关于Spring和Hibernate 的XML配置如何提示类的包路径的办法 我们在配Spring 或者Hibernate 配置文件的时候,发觉在配置类路径的时候,在双引号下 ...

  4. Spring MVC之基于xml配置的web应用构建

    2019独角兽企业重金招聘Python工程师标准>>> 更多spring博文参考: http://spring.hhui.top/ 直接用SpringBoot构建web应用可以说非常 ...

  5. Spring实战——无需一行xml配置实现自动化注入

    已经想不起来上一次买技术相关的书是什么时候了,一直以来都习惯性的下载一份电子档看看.显然,如果不是基于强烈的需求或强大的动力鞭策下,大部分的书籍也都只是蜻蜓点水,浮光掠影. 就像有位同事说的一样,有些 ...

  6. 一起来学SpringBoot | 第二篇:SpringBoot配置详解

    SpringBoot 是为了简化 Spring 应用的创建.运行.调试.部署等一系列问题而诞生的产物,自动装配的特性让我们可以更好的关注业务本身而不是外部的XML配置,我们只需遵循规范,引入相关的依赖 ...

  7. SSH框架之Spring第二篇

    1.1 基于注解的IOC配置既注解配置和xml配置要实现的功能都是一样的,都是要降低程序间的耦合.只是配置的形式不一样.1.2 环境搭建1.2.1 第一步:拷贝必备的jar包需要多拷贝一个spring ...

  8. 一步一步深入spring(6)--使用基于XML配置的spring实现的AOP

    上节我们提到了使用基于注解实现的AOP,这节我们将用基于xml配置的方式来实现的AOP. 1.首先建立一个类,作为切面类,这个类主要用来实现注解中各种通知要实现的方法. 1 package com.y ...

  9. 初学Java ssh之Spring 第二篇

    上一篇我们成功搭建好了spring开发的环境,接下来一起看看spring有什么神奇的地方吧(本人也是新手,有不太对的地方希望大神给指出便于修改呢,谢谢大家). 之前听说spring是在对xml文件的应 ...

  10. 【SpringMVC 笔记】SpringMVC 原理 + 入门项目(xml 配置版 vs 注解版)

    SpringMVC 入门项目 什么是 SpringMVC? 中心控制器 SpringMVC 执行原理 执行流程 xml 配置版 1.创建一个 Web 项目 2.pom.xml 中导入 SpringMV ...

最新文章

  1. 使用nmonchart把.nmon文件转换成html
  2. 又一壮举!GPT-3首次完成剧本创作,AI解决创造性问题的能力正迅速提升
  3. 搭建B2B2C多用户商城系统需要注意的事项
  4. 20190318-使用类做一个简单的图书馆管理系统
  5. 小汤学编程之JAVA基础day12——异常
  6. Python--面向对象学习继承(11.17)
  7. Sklearn环境搭建与常用包
  8. Servlet(1) Servlet容器和Servlet
  9. vue+element pagination分页的二次封装,带首页末页功能
  10. Python读书笔记
  11. 红米note5linux刷机包__最新最全的红米Note5ROM刷机包下载、刷机教程_红米Note5论坛_移动叔叔...
  12. 现在的自助建站都有什么特点。
  13. 黄牛用高性能服务器抢票,还在找黄牛“加速”抢票?成功抢票旅客:黄牛让我去12306候补...
  14. E-R图、N-S图、PAD图、程序流程图
  15. BZOJ1006神奇的国度
  16. 马云首次出演电影 《功守道》;沙特授予机器人公民身份;美五大科技股集体暴增1810亿美元丨价值早报
  17. 2020-09-15 ubuntu安装
  18. mysql支持kv_阿里云推出兼容Redis的KV数据库 有三大优势
  19. 人工智能定价算法的发展,使得默示共谋更为普遍
  20. CSDN获取积分规则

热门文章

  1. 程序员写代码也存在本手、妙手、俗手
  2. 学习通否认 QQ 号被盗与其有关:已报案;iPhone 14 量产工作就绪:四款齐发;简洁优雅的软件早已是明日黄花|极客头条
  3. python实现离散沃尔什变换_【图像处理】沃尔什变换与 python 实现
  4. SCORM的对手——LOM
  5. zookeeper选举机制详解
  6. 云计算数据中心的特点
  7. KEPServerEX 6 之 高级标签插件 Advanced Tags 中文使用(完整版)
  8. 2021-06-05 高效的wms仓储管理系统是关键
  9. 为什么计算机无法访问u盘,打开U盘后为什么提示拒绝访问 打开U盘后提示拒绝访问原因...
  10. vector中push_back和emplace_back区别