cannot get proxied via CGLIB

改了一些代码,启动时有个INFO的提示,虽说是INFO提示,但以前没见过;

2017-09-27 09:49:46,982 INFO (o.s.a.f.CglibAopProxy:) - Final method [private final void xxxx.xxx.AbstractDalService.baseValid(xxx.xxx.BasicDto)] cannot get proxied via CGLIB: Calls to this method will NOT be routed to the target instance and might lead to NPEs against uninitialized fields in the proxy instance.

于是打开CglibAopProxy类,看了一下原因;

      /**
	 * Checks for final methods on the given {@code Class}, as well as package-visible
	 * methods across ClassLoaders, and writes warnings to the log for each one found.
	 */
	private void doValidateClass(Class<?> proxySuperClass, ClassLoader proxyClassLoader, Set<Class<?>> ifcs) {
		if (proxySuperClass != Object.class) {
			Method[] methods = proxySuperClass.getDeclaredMethods();
			for (Method method : methods) {
				int mod = method.getModifiers();
				if (!Modifier.isStatic(mod)) {
					if (Modifier.isFinal(mod)) {
						if (implementsInterface(method, ifcs)) {
							logger.warn("Unable to proxy interface-implementing method [" + method + "] because " +
									"it is marked as final: Consider using interface-based JDK proxies instead!");
						}
						logger.info("Final method [" + method + "] cannot get proxied via CGLIB: " +
								"Calls to this method will NOT be routed to the target instance and " +
								"might lead to NPEs against uninitialized fields in the proxy instance.");
					}
					else if (!Modifier.isPublic(mod) && !Modifier.isProtected(mod) && !Modifier.isPrivate(mod) &&
							proxyClassLoader != null && proxySuperClass.getClassLoader() != proxyClassLoader) {
						logger.info("Method [" + method + "] is package-visible across different ClassLoaders " +
								"and cannot get proxied via CGLIB: Declare this method as public or protected " +
								"if you need to support invocations through the proxy.");
					}
				}
			}
			doValidateClass(proxySuperClass.getSuperclass(), proxyClassLoader, ifcs);
		}
	}

这就好改了嘛,将AbstractDalService.baseValid方法改成 static的就ok了,提示消失;

TODO

下来仔细分析一下,由其是AOP那么事;

转载于:https://my.oschina.net/u/168669/blog/1543968

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,以下是使用Dockerfile搭建LNMP环境的步骤: 1. 编写Dockerfile文件 在一个空的目录中创建一个名为Dockerfile的文件,并在其中输入以下内容: ```Dockerfile # 指定基础镜像 FROM ubuntu:18.04 # 更新软件源 RUN apt-get update # 安装 nginx RUN apt-get install -y nginx # 安装 PHP RUN apt-get install -y php-fpm php-mysql # 安装 MySQL RUN apt-get install -y mysql-server # 将配置文件复制到容器内 COPY nginx.conf /etc/nginx/nginx.conf COPY index.php /var/www/html/index.php # 暴露端口 EXPOSE 80 # 启动 nginx 和 php-fpm 服务 CMD service nginx start && service php7.2-fpm start && tail -f /var/log/nginx/access.log ``` 2. 创建Nginx的配置文件 在同一目录下创建一个名为nginx.conf的文件,并在其中输入以下内容: ```conf user www-data; worker_processes auto; pid /run/nginx.pid; events { worker_connections 768; # multi_accept on; } http { ## # Basic Settings ## sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; server_tokens off; # server_names_hash_bucket_size 64; # server_name_in_redirect off; include /etc/nginx/mime.types; default_type application/octet-stream; ## # SSL Settings ## # ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE # ssl_prefer_server_ciphers on; ## # Logging Settings ## access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; ## # Gzip Settings ## gzip on; # gzip_vary on; # gzip_proxied any; # gzip_comp_level 6; # gzip_buffers 16 8k; # gzip_http_version 1.1; # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; ## # Virtual Host Configs ## include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; server { listen 80; server_name localhost; root /var/www/html; index index.php index.html index.htm; location / { try_files $uri $uri/ /index.php?$query_string; } location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } } ``` 3. 创建PHP文件 在同一目录下创建一个名为index.php的文件,并在其中输入以下内容: ```php <?php phpinfo(); ?> ``` 4. 构建Docker镜像 在终端中进入到该目录,然后执行以下命令来构建Docker镜像: ```bash docker build -t lnmp . ``` 5. 运行Docker容器 执行以下命令来运行Docker容器: ```bash docker run -d --name lnmp -p 80:80 lnmp ``` 在运行容器之后,您可以在浏览器中输入http://localhost 来访问LNMP环境,其中172.10.1.2为nginx,172.10.0.3为PHP,172.10.0.4为MySQL。 希望这些步骤对您有所帮助。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值