Non-static method 'selectCurstateById(java.util.Map)' cannot be referenced from a static context
时间: 2023-10-28 21:42:51 浏览: 104
java.util.ConcurrentModificationException 异常问题详解1
This error message typically occurs when you try to invoke a non-static method from a static context. In Java, static methods and variables belong to the class itself, while non-static methods and variables belong to individual instances of the class.
To resolve this issue, you have a few options:
1. Create an object of the class that contains the `selectCurstateById` method and invoke the method using that object. For example:
```
MyClass obj = new MyClass();
obj.selectCurstateById(myMap);
```
2. Change the `selectCurstateById` method to be static if it doesn't rely on any instance-specific data. This way, you can call it directly from a static context. However, note that you won't be able to access non-static variables or methods within the `selectCurstateById` method.
```
public static void selectCurstateById(Map<String, Object> map) {
// method implementation
}
```
3. If the `selectCurstateById` method is intended to be an instance method and relies on instance-specific data, you need to reconsider the design of your code. You may need to rethink how you're calling the method or how you're structuring your classes.
Remember, without more context or code, it's difficult to provide a more specific solution.
阅读全文