Illegal modifier for parameter userMapper; only final is permitted
报错的原因是
package com.chen.service.impl; import java.io.IOException;
import java.io.InputStream; import org.apache.catalina.User;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext; import com.chen.mapper.UserMapper;
import com.chen.service.UserService; public class UserServiceImpl implements UserService{ //声明mapper变量
private UserMapper userMapper;//这行代码如果要加private修饰的话,就不能放在下面的代码中
public User userLoginService(String uname, String pwd) throws IOException { //获取sqlsession对象
/* InputStream is = Resources.getResourceAsStream("MyBatis.xml");
SqlSessionFactory factory = new SqlSessionFactoryBuilder().build(is);
SqlSession ss = factory.openSession();
//获取Mapper接口实例化对象
UserMapper um=ss.getMapper(UserMapper.class);*/
//当我们在applicationcontext中配置好mybatis后,就不用再像上面一样进行方法调用,获取实例化对象 //获取spring容器对象
/* ApplicationContext ac=new ClassPathXmlApplicationContext("applicationcontext.xml");
UserMapper um = (UserMapper) ac.getBean("userMapper");//mapper实例化接口的类名首字母小写即是Bean id
已经在servlet获取过一次spring容器对象了,所以我们没必要再获取一次
*/
//操作数据库
return (User) userMapper.selUser(uname, pwd);
} }
在java语法里,方法的形参以及方法体中的变量都是局部变量,不能使用访问权限修饰符public,private,protected。把Reader()方法里的所有访问权限修饰符private删除或换成final就可以。
Illegal modifier for parameter userMapper; only final is permitted的更多相关文章
- Illegal modifier for parameter *** , only final is permitted”
大家好,我想在main函数中定义一个public变量,系统报错说“Illegal modifier for parameter chatRoom, only final is permitted”,如 ...
- 修饰符(static、final、abstract)第一篇
三个修饰符: 一.static: 作用域: 1. 属性 1.1 静态属性不必要创建新对象,可直接用类调用 1.2 其值发生改变,则类中的值也会随之而变并延伸到其他对象中 例子: class Anima ...
- 【原】Java学习笔记008 - 方法(函数)
package cn.temptation; public class Sample01 { public static void main(String[] args) { // 方法/函数 Met ...
- 第三篇(那些JAVA程序BUG中的常见单词)
illegal modifier for parameter xxx; only final is permitted 参数xxx的修饰符非法:只允许final illegal 非法的 modifie ...
- Java 内存管理、JVM 工作原理与 Java 运行时系统
Java 虚拟机规范中说明:所有的对象实例(all class instances)以及数组都要在堆上分配: the heap is the runtime data area from which ...
- 【v2.x OGE教程 16】 Modifier使用相关
OGE引擎的改动器功能非常强大,为我们提供了丰富的改动器的实现类,能够改动实体的属性.提供了移动.旋转.缩放.透明.自己定义序列.同步.循环等功能,并且改变的效果能够当场生效.也能够在某一个时间段内生 ...
- 【java】聊聊java里的接口
接口的概念 java中的接口用于描述类应该具备什么样的功能,而不给出具体的实现,一个类可以“实现”多个接口 [注意]接口不是类,而是对类的一组描述 还是让我们通过一个例子来看看接口如何运作吧! ...
- java中获取接口(方法)中的参数名字(eclipse设置编译参数)(java8 javac -parameters)
interface接口参数 jdk1.7及以前使用spring功能实现的: 注意: 1.该功能只能获取类的方法的参数名,不能获取接口的方法的参数名. public static void test() ...
- 读Java 804 - Quick refresher
Upcast永远是成功的,但Downcast不是,记得做instanceof判断 仅抛不同异常,而返回值相同的重载是不可以的 static import只会import静态类 static metho ...
随机推荐
- 表格 滚动条 (tbody部分滚动)
本文是从简书复制的, markdown语法可能有些出入, 想看"正版"和更多内容请关注 简书: 小贤笔记 html <table> <thead> < ...
- C++类继承--基类new和用派生类new的区别
实际上无论是用基类还是派生类New, 结果是一样的: #include <stdio.h> class Base { public: int a; Base(){ a=0; } virtu ...
- Android fastjson
Fastjson介绍 Fastjson是一个Java语言编写的JSON处理器. 1.遵循http://json.org标准,为其官方网站收录的参考实现之一. 2.功能qiang打,支持JDK的各种类型 ...
- apache2 tomat https 变成http的解决方案
1.apache2 设置 RequestHeader set X-Forwarded-Proto "https" 2.springboot 设置 server.tomcat.p ...
- C#复制粘贴
用C#程序复制粘贴非常简单,这里为了实用,只介绍对文字的操作,其他情况类似: Clipboard.SetText(“我是需要复制到系统剪贴板的文字”); 执行以上代码后,即可ctrl+V进行粘贴.是不 ...
- shell编程报错:“syntax error near unexpected token `”
今天写了个shell脚本,在自己机器上运行正常,给同事,运行报错syntax error near unexpected token `,左看右看shell脚本没有问题,没有办法google搜索,发现 ...
- Windows ->> FIX: “The security database on the server does not have a computer account for this workstation trust relationship”
前几天在做AlwaysOn实验时遇到搭建活动目录域时某台已经加入AD的机器无法以域管理员账户登录的情况. 报错信息是:The security database on the server does ...
- Windows ->> Windows下一代文件系统 -- Resilient file system(ReFS)
Comming soon!!! 参考文献: Building the next generation file system for Windows: ReFS ReFS: What you need ...
- 【NLP_Stanford课堂】文本分类1
文本分类实例:分辨垃圾邮件.文章作者识别.作者性别识别.电影评论情感识别(积极或消极).文章主题识别及任何可分类的任务. 一.文本分类问题定义: 输入: 一个文本d 一个固定的类别集合C={c1,c2 ...
- 【Leetcode】【Medium】Convert Sorted Array to Binary Search Tree
Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 解题 ...