最近springboot项目部署服务器总是报 java.lang.NoSuchMethodError: javax.servlet.ServletContext.getVirtualServerName():异常,在本地springboot run 打包运行 都没有问题。找了半天原因觉得和jdk版本的关系。由于本地版本是1.8,服务器是1.7版本。默认版本是tomcat8,。解决方法 指定 tomcat版本就可以了。
项目启动报错,NoSuchMethod,NoSuchField,这个就是class加载过程出现了问题,需要加载类与jvm实际加载不通,机器不会骗人,下面给出我个人的排查思路。
read-only hashCode → int runtimeType → Type 方法 add(Handler handler) → Cascade 返回一个新的cascase,并将处理程序添加到末尾 noSuchMethod addMiddleware(Middleware middleware) → Pipeline 返回一个新的Pipeline,其中间件添加到现有的中间件集中 noSuchMethod(Invocation Type 方法 close() → Future 关闭服务器并返回在释放所有资源时完成的Future mount(Handler handler) → void 将处理程序挂载为此服务器的基本处理程序 noSuchMethod handler → Handler 处理程序 read-only server → Server 服务器 read-only hashCode → int runtimeType → Type 方法 noSuchMethod Exception 构造函数 HijackException() const 属性 hashCode → int runtimeType → Type 方法 toString() → String noSuchMethod
protected, inherited debugFillProperties(DiagnosticPropertiesBuilder description) → void inherited noSuchMethod protected, inherited debugFillProperties(DiagnosticPropertiesBuilder description) → void inherited noSuchMethod protected, inherited debugFillProperties(DiagnosticPropertiesBuilder description) → void inherited noSuchMethod protected, inherited debugFillProperties(DiagnosticPropertiesBuilder description) → void inherited noSuchMethod
→ StatefulElement inherited debugDescribeChildren() → List<DiagnosticsNode> @protected, inherited noSuchMethod StatelessElement inherited debugDescribeChildren() → List<DiagnosticsNode> @protected, inherited noSuchMethod StatelessElement inherited debugDescribeChildren() → List<DiagnosticsNode> @protected, inherited noSuchMethod StatelessElement inherited debugDescribeChildren() → List<DiagnosticsNode> @protected, inherited noSuchMethod
下面是个关于重写 Object 类的方法 noSuchMethod() 的例子,当代码企图用不存在的方法或实例变量时,这个方法会被调用。 class A { // 如果你不重写 noSuchMethod 方法, 就用一个不存在的成员,会导致 NoSuchMethodError 错误。 void noSuchMethod(Invocation mirror) { print('You tried to use a non-existent member:' + '${mirror.memberName}'); } } 如果你用 noSuchMethod() 实现每一个可能的 getter 方法,setter 方法和类的方法,那么你可以使用 @proxy 标注来避免警告 @proxy class A { void noSuchMethod(Invocation mirror) { // ... } } 关于注释的更多信息,请参 元数据。
依赖冲突大多场景:NoSuchMethod、NotFoundClass,方法类不一致。
ConfigurationPropertieScan和@ConstructorBinding时,诊断功能很差 部署到8.5.44之前的Tomcat 8.5和9.0.23'35之前的Tomcat 9时出现NoSuchMethod
我们要清楚一点,使用上面两种注释的方式只是让lint在编译时不再报错,在低版本的手机系统中,如果直接使用高版本的API肯定会报:“NoSuchMethod”的Crash的。
所以dart不会出现np,但是null调用其他方法会出现noSuchMethod的问题。这个体验就不是很好了。
external int get hashCode; external String toString(); @pragma("vm:entry-point") external dynamic noSuchMethod
() 为了检测或应对尝试使用不存在的方法或实例变量, 你可以复写 noSuchMethod(): class A { // Unless you override noSuchMethod, using void noSuchMethod(Invocation mirror) { print('You tried to use a non-existent member:' + '${mirror.memberName}'); } } 如果你使用 noSuchMethod() 为一个或多个类型实现可能的getter、setter、方法, 你可以使用 @proxy 注解来避免警告 : @proxy class A { void noSuchMethod(Invocation mirror) { // ... } } 一种替代 @proxy的方式是, 如果在编译时你知道有那些类型 , 就是类声明实现了的类. class A implements SomeClass, SomeOtherClass { void noSuchMethod(Invocation mirror) {
:param incoming: incoming message :type incoming: IncomingMessage :raises: NoSuchMethod, UnsupportedVersion : watchdog_thread.join() found_compatible = True if found_compatible: raise NoSuchMethod
Testoperator) return false; Testoperator person = other; return (person.x == x && person.y == y); } } 4.noSuchMethod () 要在代码尝试使用不存在的方法或实例变量时检测或做出反应,您可以重写noSuchMethod() class A { // Unless you override noSuchMethod, @override void noSuchMethod(Invocation invocation) { print('You tried to use a non-existent member: 你不能调用未实现的方法,除非以下的某一条是true: 1.接收处有静态类型dynamic 2.接收处定义了一个未实现的方法(abstract也是OK的)的静态类型dynamic,接收器的动态类型的实现与类noSuchMethod 有关更多信息,请参阅非正式 noSuchMethod转发规范 (十二)枚举类型 1.使用enum关键字声明枚举类型: 例如:enum Color { red, green, blue } 枚举中的每个值都有一个
hello 能不能自己写一个java.lang.String 1、代码书写后可以编译不会报错 2、在另一个类中加载java.lang.String,通过反射调用自己写的String类里的方法,得到结果NoSuchMethod
org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" 4、添加混淆配置 如果调试Kotlin代码,总是报ClassNotFoundException异常,或者NoSuchMethod kotlin-android-extensions依赖,同时修改proguard,解决ClassNotFoundException异常; 运行过程中报checkExpressionValueIsNotNull NoSuchMethod
protected, inherited debugFillProperties(DiagnosticPropertiesBuilder description) → void inherited noSuchMethod
native) { Instance *exception = exception_create_str(JVM_EXCEPTION_NOSUCHMETHOD, runtime NoSuchMethodException Instance *exception = exception_create_str(JVM_EXCEPTION_NOSUCHMETHOD else { Instance *exception = exception_create(JVM_EXCEPTION_NOSUCHMETHOD } else { Instance *exception = exception_create(JVM_EXCEPTION_NOSUCHMETHOD } else { Instance *exception = exception_create(JVM_EXCEPTION_NOSUCHMETHOD
==(Object other) => //类型一致且年龄一致,这里的'=='被赋值成同龄人 other is Person && age == other.age; } 重写noSuchMethod Person(this.name, this.age); void run() { print("${name} person run"); } @override dynamic noSuchMethod