标签:builder ati .com puts www. apach row tps final
报错的原因是
1 package com.chen.service.impl; 2 3 import java.io.IOException; 4 import java.io.InputStream; 5 6 import org.apache.catalina.User; 7 import org.apache.ibatis.io.Resources; 8 import org.apache.ibatis.session.SqlSession; 9 import org.apache.ibatis.session.SqlSessionFactory; 10 import org.apache.ibatis.session.SqlSessionFactoryBuilder; 11 import org.springframework.context.ApplicationContext; 12 import org.springframework.context.support.ClassPathXmlApplicationContext; 13 14 import com.chen.mapper.UserMapper; 15 import com.chen.service.UserService; 16 17 public class UserServiceImpl implements UserService{ 18 19 20 //声明mapper变量 21 private UserMapper userMapper;//这行代码如果要加private修饰的话,就不能放在下面的代码中 22 public User userLoginService(String uname, String pwd) throws IOException { 23 24 //获取sqlsession对象 25 /* InputStream is = Resources.getResourceAsStream("MyBatis.xml"); 26 SqlSessionFactory factory = new SqlSessionFactoryBuilder().build(is); 27 SqlSession ss = factory.openSession(); 28 //获取Mapper接口实例化对象 29 UserMapper um=ss.getMapper(UserMapper.class);*/ 30 //当我们在applicationcontext中配置好mybatis后,就不用再像上面一样进行方法调用,获取实例化对象 31 32 //获取spring容器对象 33 /* ApplicationContext ac=new ClassPathXmlApplicationContext("applicationcontext.xml"); 34 UserMapper um = (UserMapper) ac.getBean("userMapper");//mapper实例化接口的类名首字母小写即是Bean id 35 已经在servlet获取过一次spring容器对象了,所以我们没必要再获取一次 36 */ 37 //操作数据库 38 return (User) userMapper.selUser(uname, pwd); 39 } 40 41 }
在java语法里,方法的形参以及方法体中的变量都是局部变量,不能使用访问权限修饰符public,private,protected。把Reader()方法里的所有访问权限修饰符private删除或换成final就可以。
Illegal modifier for parameter userMapper; only final is permitted
标签:builder ati .com puts www. apach row tps final
原文地址:https://www.cnblogs.com/chen1919/p/10323209.html