首页
归档
关于
Search
1
再谈使用IdentityServer实现ASP.NET Core Web API的认证与授权
22 阅读
2
数据结构与算法
19 阅读
3
C服务器端
15 阅读
4
EF 贪婪加载 , 延迟加载,显式加载
12 阅读
5
管道处理模型
9 阅读
软件设计师笔记
.Net
Java
数据库
PHP
运维
前端
Python
中间件相关
云原生
架构设计
Search
标签搜索
websocket
科技新闻
core
Bi8bo
累计撰写
266
篇文章
累计收到
2
条评论
首页
栏目
软件设计师笔记
.Net
Java
数据库
PHP
运维
前端
Python
中间件相关
云原生
架构设计
页面
归档
关于
搜索到
81
篇与
的结果
2025-04-03
@RequestMapping注解的属性
暂无简介
2025年04月03日
0 阅读
0 评论
0 点赞
2025-04-03
@RequestParam 设置参数别名
-----------参数-------------------------------------------------------------------RequestParam来映射请求参数 required表示是否必须,默认为true defaultValue请求参数的默认值value为接收前台参数的参数名------------示例------------------------------------------------------------------@RequestMapping(value = "/testRequestParam") public String testRequestParam(@RequestParam(value="username")String name, @RequestParam(value = "age",required = false,defaultValue = "0") int age){ System.out.println("username:"+un+",age,"+age); return "success"; }1.2.3.4.5.6.http://localhost:8080/sirdifoa/test/para?username=张三&age=301.结果为:username:张三,age=30
2025年04月03日
0 阅读
0 评论
0 点赞
2025-04-03
事务默认的传播行为
REQUIRED 一定要有事务
2025年04月03日
3 阅读
0 评论
0 点赞
2025-04-03
基于Annotation方式的声明式事务
创建 spring 的配置文件导入约束并配置扫描的包1)配置事务管理器并注入数据源<!-- 配置事务管理器 --> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource"></property> </bean>(2)在配置文件中开启 spring 对注解事务的支持<!-- 开启 spring 对注解事务的支持 --> <tx:annotation-driven transaction-manager="transactionManager"/>(3)在业务层使用@Transactional 注解@Service("accountService") //只读型事务的配置 @Transactional(propagation = Propagation.SUPPORTS,readOnly = true) public class AccountServiceImpl implements AccountService { @Autowired private AccountDao accountDao; //需要的是读写型事务配置 @Transactional(propagation = Propagation.REQUIRED,readOnly = false) @Override public void transfer(String sourceName, String targetName, Float money) { //2.1根据名称查询转出账户 Account source = accountDao.findAccountByName(sourceName); //2.2根据名称查询转入账户 Account target = accountDao.findAccountByName(targetName); //2.3转出账户减钱 source.setMoney(source.getMoney() - money); //2.4转入账户加钱 target.setMoney(target.getMoney() + money); //2.5更新转出账户 accountDao.updateAccount(source); //加入异常 // int i = 1 / 0; //2.6更新转入账户 accountDao.updateAccount(target); } }
2025年04月03日
0 阅读
0 评论
0 点赞
2025-04-03
基于XML方式配置事务
配置步骤一、配置事务管理器在Bean配置文件中配置事务管理器。需要注入数据源。举个例子:<!-- 配置事务管理器 --> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource"></property> </bean>二、 配置事务属性需要先导入 tx 命名空间。使用<tx:advice>元素声明事务通知,需要指定id属性,以便AOP把通知和切入点关联起来。还需要指定transaction-manager属性,其值Bean配置文件中事务管理器的id属性值。在<tx:advice>元素下声明<tx:attributes>元素,用于指定事务属性。在<tx:attributes>元素下可以使用多个<tx:method>元素指定多种事务属性。举个例子:<!-- 配置事务通知 --> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <!-- 根据方法名指定事务的属性 --> <tx:method name="BookShopXmlService" propagation="REQUIRED"/> <tx:method name="get*" read-only="true"/> <tx:method name="find*" read-only="true"/> <tx:method name="*"/> </tx:attributes> </tx:advice>三、 配置事务切入点,把事务切入点与事务关联起来在 <aop:config>元素下,使用<aop:pointcut>元素声明切入点,其expression属性指定切入点表达式,还需要指定id属性。在 在<aop:config>元素下,使用<aop:advisor>元素声明一个增强器,将事务通知和切入点关联起来,使用 advice-ref属性指定事务通知,用pointcut-ref属性指定切入点。举个例子:<!-- 配置事务切入点,以及把事务切入点和事务属性关联起来 --> <aop:config> <aop:pointcut expression="execution(* com.sqp.spring.service.*.*(..))" id="txPointcut"/> <aop:advisor advice-ref="txAdvice" pointcut-ref="txPointcut"/> </aop:config>tx:method属性详解https://blog.csdn.net/weixin_46053707/article/details/104498698
2025年04月03日
0 阅读
0 评论
0 点赞
1
...
5
6
7
...
17