云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > Spring笔试考试题目

Spring笔试考试题目

  • 62 次阅读
  • 3 次下载
  • 2025/5/24 13:46:18

public void beforeGreeting(){

System.out.println(\ } }

//第二个切面类的定义

package com.cstp.aspectj.advanced;

import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; @Aspect

public class BeforeAspect{

@Before(\ public void bindJoinPointParams(int num,String name){ System.out.println(\ System.out.println(\ System.out.println(\

System.out.println(\ } }

//下面是定义的Spring配置文件beans.xml

xsi:schemaLocation=\ http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aop

http://www.springframework.org/schema/aop/spring-aop-2.0.xsd\ ______________________________(1)

//下面是测试的代码

package com.cstp.aspectj.example;

import org.springframework.aop.aspectj.annotation.AspectJProxyFactory; import org.cstp.NaiveWaiter; import org.cstp.Waiter; public class Test{

public static void main(String[] args){

ApplicationContext tx=new ClassPathXmlApplicationContext(“com/cstp/schema/beans.xml”); NaiveWaiter proxy=tx.getBean(“waiter”); proxy.greetTo(\ proxy.serveTo(\ } }

请回答下面问题:

1).首先,请填写上面的空白(1)处。 2).请写出测试代码运行后的结果。

3).如果我们要把第一个切面类采用Schema XML方式来完成,请写出该种方式的配置文件,只需要写出中配置增强和切点的方式。

五:编程(总分10分)

5.1:下面是一个需要进行事务管理的业务类, package com.cstp.service;

import com.cstp.dao.LoginLogDao; import com.cstp.dao.UserDao; import com.cstp.domain.User;

public class UserServiceImpl implements UserService{ private UserDao userDao; //注入接口对象

private LoginLogDao loginLogDao; //注入接口对象 public void setUserDao(UserDao userDao){ this.userDao=userDao; }

public void setLoginLogDao(LoginLogDao loginLogDao){ this.loginLogDao=loginLogDao; }

public boolean hasMatchUser throws Exception(String userName, String password){ int matchCount=userDao.getMatchCount(useName, password); return matchCount>0; }

public User findUserByUserName throws Exception (String userName){ return userDao.findUserByUserName(userName); }

public void loginSuccess throws Exception (User user){ user.setCredits(5+user.getCredits()); LoginLog loginLog=new LoginLog(); loginLog.setUserId(user.getUserId()); loginLog.setIp(user.getLastIp());

loginLog.setLoginDate(user.getLastVisit()); userDao.updateLoginInfor(user);

loginLogDao.insertLoginLog(loginLog); } }

其中hasMatchUser(),findUserByUserName(),loginSuccess()需要的事务管理需求描述如下:

hasMatchUser():只读事务,事务传播方式必须有事务管理,隔离级别是不能出现脏读,出现SQLException需要回滚。

findUserByUserName():只读事务,事务传播方式可以没有事务管理,隔离级别是不能出现脏读,出现任何Exception不需要回滚。

loginSuccess():可写事务,事务传播方式是强制方式,隔离级别是不能出现脏读,出现任何Exception需要回滚。

(1) 写出该业务类使用注解来实现事务管理的完整形式。

(2) 写出该业务类使用Schema XML方式来实现事务管理的完整形式(填入下面即可)。

xsi:schemaLocation=\

http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/tx

http://www.springframework.org/schema/tx/spring-tx-2.0.xsd http://www.springframework.org/schema/aop

http://www.springframework.org/schema/aop/spring-aop-2.0.xsd\

搜索更多关于: Spring笔试考试题目 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

public void beforeGreeting(){ System.out.println(\ } } //第二个切面类的定义 package com.cstp.aspectj.advanced; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; @Aspect public class BeforeAspect{ @Before(\ public void bindJoinPointParams(int num,String name){ System.out.println(\ System.out.println(\ System.out.println

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com