Skip to Main Content

Chinese

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

weblogic 12c(12.2.1.4.0)发布的应用程序重复启动后,类中的静态变量还是引用的第一次启动时的值

user-kkgsbOct 29 2023

weblogic 12c(12.2.1.4.0)发布的应用程序重复启动后,类中的静态变量还是引用的第一次启动时的值。

通过控制台:

中的启动和停止,来回启动和停止,第二次以及后续启动过程,类引用的变量都是第一次获取的变量,代码如下:

public class SqlBaseUtils {
	private static IBaseService service = null;
	
	public static BaseDTO getSqlRuleData(String tbcode, String tbtype, BaseDTO reqDto) throws Exception { 
		if (BaseUtils.isEmpty(service)) { 
			//service 第一次启动为空,赋值后,重新启动后,server都不为空,未获取到最新的值,baseService为spring bean
			service = (IBaseService)BaseUtils.getServiceBean("baseService"); 
		} 
		......
		return tempDto; 
	}
}

//导致获取到过期对象,第二次及后续启动程序都失败,请问weblogic停止后不会卸载静态变量吗?

Comments

Post Details

Added on Oct 29 2023
0 comments
260 views