新手 java json NullPointerException异常

最近在用websocket做聊天室 ,用gson 传数据的时候老是错误 ,郁闷死了,求帮助

图片说明

图片说明

5个回答

 static Gson gson;

改为

 static Gson gson = new Gson();

Gson转json操作是线程安全的,可以静态使用。

你的gson没有被实例化,你使用spring的话可以使用自动注入,如果没有使用spring的话手动实例化一下。

Gson没有进行实例化,直接掉肯定nullpoint

https://github.com/google/gson/blob/master/UserGuide.md#object-examples

官方文档。

 class BagOfPrimitives {
  private int value1 = 1;
  private String value2 = "abc";
  private transient int value3 = 3;
  BagOfPrimitives() {
    // no-args constructor
  }
}

// Serialization
BagOfPrimitives obj = new BagOfPrimitives();
Gson gson = new Gson();
String json = gson.toJson(obj);  

// ==> json is {"value1":1,"value2":"abc"}

你少了一句Gson gson = new Gson();加在gson.toJson()上面就可以了。

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
java 中出现 java.lang.nullpointerexception异常
java 中出现 java.lang.nullpointerexception异常,哪位大神能帮忙处理一下 http://pan.baidu.com/share/link?shareid=3804041701&uk=840289731
关于Java中NullPointerException异常的请教
``` public class Distribution { private Idiot [] idiot; public Distribution(){ this.idiot=new Idiot[5]; Chopsticks [] cp = new Chopsticks[5]; for(int i=0; i<5;i++){ this.idiot[i].setLEFT_CHOPSTICKS(cp[i]); //报错是这里有问题 if(i == 0){ this.idiot[i].setRIGHT_CHOPSTICKS(cp[4]); }else{ this.idiot[i].setRIGHT_CHOPSTICKS(cp[i-1]); } } } public static void main(String [] args) { Distribution distribution = new Distribution(); } } ``` ``` public class Idiot { private Chopsticks LEFT_CHOPSTICKS=null; private Chopsticks RIGHT_CHOPSTICKS=null; public Chopsticks getLEFT_CHOPSTICKS() { return LEFT_CHOPSTICKS; } public void setLEFT_CHOPSTICKS(Chopsticks left_chopsticks) { LEFT_CHOPSTICKS = left_chopsticks; } public Chopsticks getRIGHT_CHOPSTICKS() { return RIGHT_CHOPSTICKS; } public void setRIGHT_CHOPSTICKS(Chopsticks right_chopsticks) { RIGHT_CHOPSTICKS = right_chopsticks; } } ``` ``` public class Chopsticks { private boolean USING_STATE; public Chopsticks(){ this.USING_STATE=false; } public void setUSING_STATE(boolean using_state) { USING_STATE = using_state; } public boolean isUSING_STATE() { return USING_STATE; } } ``` ``` Exception in thread "main" java.lang.NullPointerException at Distribution.<init>(Distribution.java:8) at Distribution.main(Distribution.java:18) ``` 请问是哪里有问题 该怎么改
Java的NullPointerException是什么,我如何修复它?
Java的Nullpointerexception是什么原因导致的?用什么方法才能确定原因,以防止异常导致程序过早终止?
java.lang.NullPointerException异常如何解决
报错位置如下:![图片说明](https://img-ask.csdn.net/upload/201909/23/1569227247_68440.png) 报错如下:![图片说明](https://img-ask.csdn.net/upload/201909/23/1569227258_9261.png) 不知道该如何解决,希望高手可以指点一下,谢谢。 补充:根据回复两位的提示,确实是因为nrofCopies为null引起的, private Map<String, Object> properties; public Object getProperty(String key) { if (this.properties == null) { //程序进入到了这里 return null; } return this.properties.get(key); } 请问如何解决呢
Spring java.lang.NullPointerException异常
初学Sping ![图片说明](https://img-ask.csdn.net/upload/201610/18/1476769770_847496.png) ![图片说明](https://img-ask.csdn.net/upload/201610/18/1476769782_511960.png) ![图片说明](https://img-ask.csdn.net/upload/201610/18/1476769801_376192.png) ![图片说明](https://img-ask.csdn.net/upload/201610/18/1476769812_182676.png) ![图片说明](https://img-ask.csdn.net/upload/201610/18/1476769822_330497.png) ![图片说明](https://img-ask.csdn.net/upload/201610/18/1476769845_196556.png)
多线程工具类普通类调用server层空指针异常,请问该如何解决
springboot中多线程工具类普通类调用server层空指针异常 ``` java.lang.NullPointerException at com.example.spr.utils.thread.TestThread$1.run(TestThread.java:31) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) ```
关于java中NullPointerException,求帮忙——来自java菜鸟的呼声
package test1; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Random; import java.util.Set; public class CountNumber //对数字进行计数并统计出每个数字出现的次数 { public static void main(String[] args) { Random random = new Random(); HashMap map = new HashMap(); for(int i = 0; i < 50 ; i ++) //随机生成50的数并以map类对象存储 { int a = random.nextInt(); if((Integer)a == null) //如果该key指向null,说明未出现过,直接存入map中 { map.put(a, new Integer(1)); } else //否则出现过,将key对应的value值加1 { //程序在这行报错 java.lang.NullPointerException map.put(a,new Integer((Integer)(map.get(a))).intValue() + 1); } } Set set = map.entrySet(); for(Iterator itr = set.iterator();itr.hasNext(); ) { Map.Entry s = (Map.Entry)itr.next(); String key = (String)s.getKey(); String value = (String)s.getValue(); System.out.print(key + " " + value); } } }
新建servlet项目 报nullpointerexception异常
初学servlet 新建servlet项目报nullpointerexception异常 ![图片说明](https://img-ask.csdn.net/upload/201805/22/1527002467_162817.png) web.xml配置文件 ![图片说明](https://img-ask.csdn.net/upload/201805/22/1527002498_393435.png) 目录 ![图片说明](https://img-ask.csdn.net/upload/201805/22/1527002531_120619.png) HelloWorldServlet代码 ![图片说明](https://img-ask.csdn.net/upload/201805/22/1527002701_22668.png)
启动Activity出现NullPointerException异常
package com.charming.sensor; import android.app.Activity; import android.content.Context; import android.graphics.Color; import android.hardware.Sensor; import android.hardware.SensorEvent; import android.hardware.SensorEventListener; import android.hardware.SensorManager; import android.os.Bundle; import android.view.View; import android.widget.TextView; public class MainActivity extends Activity implements SensorEventListener { private TextView valueView; private View top, left, right, bottom; private SensorManager sensorManager; private Sensor accelerometer; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); init(); } private void init() { valueView = (TextView) findViewById(R.id.values); top = findViewById(R.id.top); bottom = findViewById(R.id.bottom); left = findViewById(R.id.left); right = findViewById(R.id.right); sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); accelerometer = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); } @Override protected void onResume() { super.onResume(); sensorManager.registerListener(this, accelerometer, SensorManager.SENSOR_DELAY_UI); } @Override protected void onPause() { super.onPause(); sensorManager.unregisterListener(this); } @Override public void onSensorChanged(SensorEvent event) { float[] values = event.values; float x = values[0] / 10; float y = values[1] / 10; int scaleFactor; if (x > 0) { scaleFactor = (int) Math.min(x * 255, 255); right.setBackgroundColor(Color.argb(scaleFactor, 255, 0, 0)); left.setBackgroundColor(Color.TRANSPARENT); } else { scaleFactor = (int) Math.min(x * 255, 255); left.setBackgroundColor(Color.argb(scaleFactor, 255, 0, 0)); right.setBackgroundColor(Color.TRANSPARENT); } if (y > 0) { scaleFactor = (int) Math.min(x * 255, 255); top.setBackgroundColor(Color.argb(scaleFactor, 255, 0, 0)); bottom.setBackgroundColor(Color.TRANSPARENT); } else { scaleFactor = (int) Math.min(x * 255, 255); bottom.setBackgroundColor(Color.argb(scaleFactor, 255, 0, 0)); top.setBackgroundColor(Color.TRANSPARENT); } valueView.setText("x:" + x + " " + "y:" + y); } @Override public void onAccuracyChanged(Sensor sensor, int accuracy) { } } 布局文件 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/activity_main" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.charming.sensor.MainActivity"> <TableLayout android:layout_width="match_parent" android:layout_height="match_parent" android:stretchColumns="0, 1, 2"> <TableRow android:layout_weight="1"> <view android:id="@+id/top" android:layout_column="1" /> </TableRow> <TableRow android:layout_weight="1"> <view android:id="@+id/left" android:layout_column="0" /> <view android:id="@+id/right" android:layout_column="2" /> </TableRow> <TableRow android:layout_weight="1"> <view android:id="@+id/bottom" android:layout_column="1" /> </TableRow> </TableLayout> <TextView android:id="@+id/values" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" /> </RelativeLayout> log E/AndroidRuntime: FATAL EXCEPTION: main Process: com.charming.myapplication, PID: 7837 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.charming.myapplication/com.charming.myapplication.MainActivity}: android.view.InflateException: Binary XML file line #16: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) at android.app.ActivityThread.-wrap11(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) Caused by: android.view.InflateException: Binary XML file line #16: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference at android.view.LayoutInflater.inflate(LayoutInflater.java:539) at android.view.LayoutInflater.inflate(LayoutInflater.java:423) at android.view.LayoutInflater.inflate(LayoutInflater.java:374) at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:393) at android.app.Activity.setContentView(Activity.java:2166) at com.charming.myapplication.MainActivity.onCreate(MainActivity.java:24) at android.app.Activity.performCreate(Activity.java:6237) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)  at android.app.ActivityThread.-wrap11(ActivityThread.java)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:148)  at android.app.ActivityThread.main(ActivityThread.java:5417)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)  Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:738) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) at android.view.LayoutInflater.rInflate(LayoutInflater.java:835) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) at android.view.LayoutInflater.rInflate(LayoutInflater.java:838) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) at android.view.LayoutInflater.rInflate(LayoutInflater.java:838) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) at android.view.LayoutInflater.inflate(LayoutInflater.java:515) at android.view.LayoutInflater.inflate(LayoutInflater.java:423)  at android.view.LayoutInflater.inflate(LayoutInflater.java:374)  at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:393)  at android.app.Activity.setContentView(Activity.java:2166)  at com.charming.myapplication.MainActivity.onCreate(MainActivity.java:24)  at android.app.Activity.performCreate(Activity.java:6237)  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)  at android.app.ActivityThread.-wrap11(ActivityThread.java)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:148)  at android.app.ActivityThread.main(ActivityThread.java:5417)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
springboot:后台显示java.lang.NullPointerException: null
![图片说明](https://img-ask.csdn.net/upload/202001/10/1578628955_760523.png) ![图片说明](https://img-ask.csdn.net/upload/202001/10/1578628552_649627.png) ![图片说明](https://img-ask.csdn.net/upload/202001/10/1578627276_206035.png)![图片说明](https://img-ask.csdn.net/upload/202001/10/1578627288_389314.png)
ArrayAdapter报出NullPointerException异常
在Activity中有一个listview。listview中使用arrayAdapter布局填充。array Adapter是从Activity中调用的。Activity传递一个arrayList对象到adapter。当执行Activity获得空指针异常。使用的以下的代码,要改哪里啊? 谢谢大家的指导! public class OpenTicketList extends Activity implements OnItemClickListener{ private Bundle basket; private AdapterTicketList adapterTicketList; private List<Ticket> openTicketList; private ListView listView; @TargetApi(9) public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); Log.i("OpenTicket","on create"); setContentView(R.layout.openticketlist); catchBasket(); initialize(); } private void initialize() { listView=(ListView)findViewById(R.id.lvOpenTicketList); POJO_Ticket pojo_Ticket; ArrayList<POJO_Ticket> ticketArray; ticketArray = new ArrayList<POJO_Ticket>(); for(int i=0;i<openTicketList.size();i++){ pojo_Ticket = new POJO_Ticket(openTicketList.get(i)); ticketArray.add(pojo_Ticket); Log.i("OpenTicket","i = " + Integer.toString(i)); } adapterTicketList=new AdapterTicketList(this, ticketArray); listView.setAdapter(adapterTicketList); listView.setOnItemClickListener(this); } private void catchBasket() { // TODO Auto-generated method stub basket = getIntent().getExtras(); openTicketList = (List<Ticket>) basket.getSerializable("ticket"); } } public class AdapterTicketList extends ArrayAdapter<POJO_Ticket> { Context context; ArrayList<POJO_Ticket> ticketArray; LayoutInflater vi; public AdapterTicketList(Context context , ArrayList<POJO_Ticket> ticketArray) { super(context, 0, ticketArray ); this.ticketArray = new ArrayList<POJO_Ticket>(); this.ticketArray.addAll(ticketArray); this.context =context; Log.i("AdapterTicketList"," ticket id : " + ticketArray.get(0).getTicketObject().getId()); vi = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } private class ViewHolder { TextView tvTicketID; TextView tvCreationHour; TextView tvTableNumber; TextView tvAmount; } public View getView(final int position, View convertView, ViewGroup parent) { ViewHolder holder; if (convertView == null) { holder = new ViewHolder(); convertView = vi.inflate(R.layout.rowticket, null); holder.tvTicketID = (TextView) convertView.findViewById(R.id.tvTicketID); holder.tvCreationHour = (TextView) convertView.findViewById(R.id.tvCreationHour); holder.tvTableNumber = (TextView) convertView.findViewById(R.id.tvTableNumber); holder.tvAmount = (TextView) convertView.findViewById(R.id.tvQuantity); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } 相关异常: 01-08 23:01:55.287: E/AndroidRuntime(7791): FATAL EXCEPTION: main 01-08 23:01:55.287: E/AndroidRuntime(7791): android.content.res.Resources: String resource ID #0x11 01-08 23:01:55.287: E/AndroidRuntime(7791): at android.content.res.Resources.getText(Resources.java:247) 01-08 23:01:55.287: E/AndroidRuntime(7791): at android.widget.TextView.setText(TextView.java:3495) 01-08 23:01:55.287: E/AndroidRuntime(7791): at com.example.restaurent.AdapterTicketList.getView(AdapterTicketList.java:52) 01-08 23:01:55.287: E/AndroidRuntime(7791): at android.widget.AbsListView.obtainView(AbsListView.java:2040) 01-08 23:01:55.287: E/AndroidRuntime(7791): at android.widget.ListView.makeAndAddView(ListView.java:1772) 01-08 23:01:55.287: E/AndroidRuntime(7791): at android.widget.ListView.fillDown(ListView.java:672) 01-08 23:01:55.287: E/AndroidRuntime(7791): at android.widget.ListView.fillFromTop(ListView.java:732) 01-08 23:01:55.287: E/AndroidRuntime(7791): at android.widget.ListView.layoutChildren(ListView.java:1625) 01-08 23:01:55.287: E/AndroidRuntime(7791): at android.widget.AbsListView.onLayout(AbsListView.java:1870) 01-08 23:01:55.287: E/AndroidRuntime(7791): at android.view.View.layout(View.java:11418) 01-08 23:01:55.287: E/AndroidRuntime(7791): at android.view.ViewGroup.layout(ViewGroup.java:4328) 01-08 23:01:55.287: E/AndroidRuntime(7791): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1652) 01-08 23:01:55.287: E/AndroidRuntime(7791): at android.widget.LinearLayout.layoutHorizontal(LinearLayout.java:1641) 01-08 23:01:55.287: E/AndroidRuntime(7791): at android.widget.LinearLayout.onLayout(LinearLayout.java:1417) 01-08 23:01:55.287: E/AndroidRuntime(7791): at android.view.View.layout(View.java:11418) 01-08 23:01:55.287: E/AndroidRuntime(7791): at android.view.ViewGroup.layout(ViewGroup.java:4328) 01-08 23:01:55.287: E/AndroidRuntime(7791): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1652) 01-08 23:01:55.287: E/AndroidRuntime(7791): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1510) 01-08 23:01:55.287: E/AndroidRuntime(7791): at android.widget.LinearLayout.onLayout(LinearLayout.java:1415) 01-08 23:01:55.287: E/AndroidRuntime(7791): at android.view.View.layout(View.java:11418) 01-08 23:01:55.287: E/AndroidRuntime(7791): at android.view.ViewGroup.layout(ViewGroup.java:4328) 01-08 23:01:55.287: E/AndroidRuntime(7791): at android.widget.FrameLayout.onLayout(FrameLayout.java:443) 01-08 23:01:55.287: E/AndroidRuntime(7791): at android.view.View.layout(View.java:11418) 01-08 23:01:55.287: E/AndroidRuntime(7791): at android.view.ViewGroup.layout(ViewGroup.java:4328) 01-08 23:01:55.287: E/AndroidRuntime(7791): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1652) 01-08 23:01:55.287: E/AndroidRuntime(7791): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1510) 01-08 23:01:55.287: E/AndroidRuntime(7791): at android.widget.LinearLayout.onLayout(LinearLayout.java:1415) 01-08 23:01:55.287: E/AndroidRuntime(7791): at android.view.View.layout(View.java:11418) 01-08 23:01:55.287: E/AndroidRuntime(7791): at android.view.ViewGroup.layout(ViewGroup.java:4328) 01-08 23:01:55.287: E/AndroidRuntime(7791): at android.widget.FrameLayout.onLayout(FrameLayout.java:443) 01-08 23:01:55.287: E/AndroidRuntime(7791): at android.view.View.layout(View.java:11418) 01-08 23:01:55.287: E/AndroidRuntime(7791): at android.view.ViewGroup.layout(ViewGroup.java:4328) 01-08 23:01:55.287: E/AndroidRuntime(7791): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1489) 01-08 23:01:55.287: E/AndroidRuntime(7791): at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2442) 01-08 23:01:55.287: E/AndroidRuntime(7791): at android.os.Handler.dispatchMessage(Handler.java:99) 01-08 23:01:55.287: E/AndroidRuntime(7791): at android.os.Looper.loop(Looper.java:137) 01-08 23:01:55.287: E/AndroidRuntime(7791): at android.app.ActivityThread.main(ActivityThread.java:4441) 01-08 23:01:55.287: E/AndroidRuntime(7791): at java.lang.reflect.Method.invokeNative(Native Method) 01-08 23:01:55.287: E/AndroidRuntime(7791): at java.lang.reflect.Method.invoke(Method.java:511) 01-08 23:01:55.287: E/AndroidRuntime(7791): at com.android.internal.os.ZygoteInit.run(ZygoteInit.java:784) 01-08 23:01:55.287: E/AndroidRuntime(7791): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 01-08 23:01:55.287: E/AndroidRuntime(7791): at dalvik.system.NativeStart.main(Native Method)
java.lang.NullPointerException?空指向异常是与数据库有关吗?
java.lang.NullPointerException com.wgh.tools.ConnDB.executeQuery(ConnDB.java:56) com.wgh.dao.DiaryDao.queryDiary(DiaryDao.java:28) com.wgh.servlet.DiaryServlet.listAllDiary(DiaryServlet.java:249) com.wgh.servlet.DiaryServlet.doPost(DiaryServlet.java:52) com.wgh.servlet.DiaryServlet.doGet(DiaryServlet.java:66) javax.servlet.http.HttpServlet.service(HttpServlet.java:624) javax.servlet.http.HttpServlet.service(HttpServlet.java:731) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) com.wgh.filter.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:24) 空指向异常,这个是与数据库有关吗?怎么解决,请高手帮忙解答,感激不尽。
Exception in thread "Thread-12" java.lang.RuntimeException: java.lang.NullPointerException
第一次着手项目,springboot+mybatis,项目搭建是跟着教程做的。项目搭建好之后项目能正常运行,但是启动后报: Exception in thread "Thread-12" java.lang.RuntimeException: java.lang.NullPointerException at com.mysql.jdbc.JDBC4Connection$1$1.run(JDBC4Connection.java:106) Caused by: java.lang.NullPointerException at com.mysql.jdbc.ConnectionImpl.abortInternal(ConnectionImpl.java:1240) at com.mysql.jdbc.JDBC4Connection$1$1.run(JDBC4Connection.java:104) 启动Console: 2019-08-05 10:29:12.921 INFO 7416 --- [ restartedMain] com.xintujiuzhang.aimanagement.App : Starting App on DESKTOP-J57CTN6 with PID 7416 (D:\JAVA\eclipse\TaxHandwritingRecognition\target\classes started by Administrator in D:\JAVA\eclipse\TaxHandwritingRecognition) 2019-08-05 10:29:12.921 INFO 7416 --- [ restartedMain] com.xintujiuzhang.aimanagement.App : No active profile set, falling back to default profiles: default 2019-08-05 10:29:12.958 INFO 7416 --- [ restartedMain] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@6070b0bb: startup date [Mon Aug 05 10:29:12 CST 2019]; root of context hierarchy 2019-08-05 10:29:13.450 INFO 7416 --- [ restartedMain] o.s.b.f.xml.XmlBeanDefinitionReader : Loading XML bean definitions from class path resource [mybatis-config.xml] 2019-08-05 10:29:13.503 INFO 7416 --- [ restartedMain] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'sqlSessionFactory' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=app; factoryMethodName=sqlSessionFactoryBean; initMethodName=null; destroyMethodName=(inferred); defined in com.xintujiuzhang.aimanagement.App] with [Generic bean: class [org.mybatis.spring.SqlSessionFactoryBean]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in class path resource [mybatis-config.xml]] 2019-08-05 10:29:13.599 WARN 7416 --- [ restartedMain] o.m.s.mapper.ClassPathMapperScanner : No MyBatis mapper was found in '[com.xintujiuzhang.aimanagement]' package. Please check your configuration. 2019-08-05 10:29:13.958 INFO 7416 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$b535b905] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2019-08-05 10:29:14.332 INFO 7416 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http) 2019-08-05 10:29:14.348 INFO 7416 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2019-08-05 10:29:14.349 INFO 7416 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.28 2019-08-05 10:29:14.355 INFO 7416 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener : Loaded APR based Apache Tomcat Native library [1.2.21] using APR version [1.6.5]. 2019-08-05 10:29:14.355 INFO 7416 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener : APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true]. 2019-08-05 10:29:14.355 INFO 7416 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener : APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true] 2019-08-05 10:29:14.357 INFO 7416 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener : OpenSSL successfully initialized [OpenSSL 1.1.1a 20 Nov 2018] 2019-08-05 10:29:14.418 INFO 7416 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2019-08-05 10:29:14.418 INFO 7416 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1462 ms 2019-08-05 10:29:14.514 INFO 7416 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/] 2019-08-05 10:29:14.517 INFO 7416 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*] 2019-08-05 10:29:14.517 INFO 7416 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*] 2019-08-05 10:29:14.517 INFO 7416 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*] 2019-08-05 10:29:14.517 INFO 7416 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*] 2019-08-05 10:29:14.631 INFO 7416 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting... 2019-08-05 10:29:19.625 INFO 7416 --- [ restartedMain] com.zaxxer.hikari.pool.PoolBase : HikariPool-1 - Driver does not support get/set network timeout for connections. (com.mysql.jdbc.JDBC4Connection.getNetworkTimeout()I) 2019-08-05 10:29:19.629 INFO 7416 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed. 2019-08-05 10:29:19.670 INFO 7416 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default' 2019-08-05 10:29:19.684 INFO 7416 --- [ restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [ name: default ...] 2019-08-05 10:29:19.738 INFO 7416 --- [ restartedMain] org.hibernate.Version : HHH000412: Hibernate Core {5.2.10.Final} 2019-08-05 10:29:19.739 INFO 7416 --- [ restartedMain] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found 2019-08-05 10:29:19.770 INFO 7416 --- [ restartedMain] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.1.Final} 2019-08-05 10:29:19.874 INFO 7416 --- [ restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect 2019-08-05 10:29:19.897 INFO 7416 --- [ restartedMain] o.h.e.j.e.i.LobCreatorBuilderImpl : HHH000423: Disabling contextual LOB creation as JDBC driver reported JDBC version [3] less than 4 2019-08-05 10:29:20.037 INFO 7416 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default' 10:29:20,543 INFO App:32-org.springframework.orm.jpa.JpaTransactionManager 2019-08-05 10:29:20.796 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@6070b0bb: startup date [Mon Aug 05 10:29:12 CST 2019]; root of context hierarchy 2019-08-05 10:29:20.824 WARN 7416 --- [ restartedMain] aWebConfiguration$JpaWebMvcConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning 2019-08-05 10:29:20.846 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/application/handwriting_authorization],methods=[GET]}" onto public java.lang.String com.xintujiuzhang.aimanagement.controller.ApplicationAuthorizationController.joinHWA(java.util.Map<java.lang.String, java.lang.Object>) 2019-08-05 10:29:20.847 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/application/handwriting_information],methods=[GET]}" onto public java.lang.String com.xintujiuzhang.aimanagement.controller.ApplicationInformationController.joinHWI(java.util.Map<java.lang.String, java.lang.Object>) 2019-08-05 10:29:20.847 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/log/background_management_login],methods=[GET]}" onto public java.lang.String com.xintujiuzhang.aimanagement.controller.BackgroundManagementLoginController.joinHWI(java.util.Map<java.lang.String, java.lang.Object>) 2019-08-05 10:29:20.847 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/log/computer_login],methods=[GET]}" onto public java.lang.String com.xintujiuzhang.aimanagement.controller.ComputerLoginController.jumpDEM(java.util.Map<java.lang.String, java.lang.Object>) 2019-08-05 10:29:20.847 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/authority/department_management],methods=[GET]}" onto public java.lang.String com.xintujiuzhang.aimanagement.controller.DepartmentManagementController.jumpDEM(java.util.Map<java.lang.String, java.lang.Object>) 2019-08-05 10:29:20.848 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/authority/dictionary_management],methods=[GET]}" onto public java.lang.String com.xintujiuzhang.aimanagement.controller.DictionaryManagementController.jumpDM(java.util.Map<java.lang.String, java.lang.Object>) 2019-08-05 10:29:20.848 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/equipment/hardware_devices],methods=[GET]}" onto public java.lang.String com.xintujiuzhang.aimanagement.controller.EquipmentManagementController.jumpDM(java.util.Map<java.lang.String, java.lang.Object>) 2019-08-05 10:29:20.848 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/queryGetServerStatusInterface],methods=[GET]}" onto public java.util.Map<java.lang.String, java.lang.Object> com.xintujiuzhang.aimanagement.controller.GetServerStatusInterfaceController.queryGetServerStatus(java.lang.String,java.lang.String) 2019-08-05 10:29:20.848 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/queryHandwritingInterface],methods=[GET]}" onto public java.util.Map<java.lang.String, java.lang.Object> com.xintujiuzhang.aimanagement.controller.HandwritingInterfaceController.queryHandwriting(java.lang.String,java.lang.String,java.lang.Integer,java.util.Date) 2019-08-05 10:29:20.849 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/identity/identity_management],methods=[GET]}" onto public java.lang.String com.xintujiuzhang.aimanagement.controller.IdentityManagementController.jumpDM(java.util.Map<java.lang.String, java.lang.Object>) 2019-08-05 10:29:20.849 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/queryInstallationRequest],methods=[GET]}" onto public java.util.Map<java.lang.String, java.lang.Object> com.xintujiuzhang.aimanagement.controller.InstallationRequestInterfaceController.queryInstallationRequest(java.lang.String,java.lang.String,java.lang.String) 2019-08-05 10:29:20.849 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/queryLicenseInterface],methods=[GET]}" onto public java.util.Map<java.lang.String, java.lang.Object> com.xintujiuzhang.aimanagement.controller.LicenseInterfaceController.queryLicense(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.util.Date) 2019-08-05 10:29:20.851 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/]}" onto public java.lang.String com.xintujiuzhang.aimanagement.controller.MainController.main(java.util.Map<java.lang.String, java.lang.Object>) 2019-08-05 10:29:20.851 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/login],methods=[GET]}" onto public org.springframework.web.servlet.ModelAndView com.xintujiuzhang.aimanagement.controller.MainController.login() 2019-08-05 10:29:20.851 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/login],methods=[POST]}" onto public java.lang.String com.xintujiuzhang.aimanagement.controller.MainController.login(java.lang.String,java.lang.String,java.util.Map<java.lang.String, java.lang.Object>) 2019-08-05 10:29:20.851 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/main],methods=[GET]}" onto public java.lang.String com.xintujiuzhang.aimanagement.controller.MainController.jumpmain(java.util.Map<java.lang.String, java.lang.Object>) 2019-08-05 10:29:20.852 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/authority/menu_management],methods=[GET]}" onto public java.lang.String com.xintujiuzhang.aimanagement.controller.MenuManagementController.jumpMM(java.util.Map<java.lang.String, java.lang.Object>) 2019-08-05 10:29:20.852 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/log/module_browsing],methods=[GET]}" onto public java.lang.String com.xintujiuzhang.aimanagement.controller.ModuleBrowsingController.jumpTM(java.util.Map<java.lang.String, java.lang.Object>) 2019-08-05 10:29:20.852 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/log/module_operation],methods=[GET]}" onto public java.lang.String com.xintujiuzhang.aimanagement.controller.ModuleOperationController.jumpMM(java.util.Map<java.lang.String, java.lang.Object>) 2019-08-05 10:29:20.852 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/deletehandwriting],methods=[POST]}" onto public void com.xintujiuzhang.aimanagement.controller.NotesController.deletehandwriting(java.lang.String) 2019-08-05 10:29:20.852 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/updatehandwriting],methods=[POST]}" onto public void com.xintujiuzhang.aimanagement.controller.NotesController.updatehandwriting(com.xintujiuzhang.aimanagement.pojo.Handwriting) 2019-08-05 10:29:20.852 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/addhandwriting],methods=[POST]}" onto public void com.xintujiuzhang.aimanagement.controller.NotesController.addhandwriting(com.xintujiuzhang.aimanagement.pojo.Handwriting) 2019-08-05 10:29:20.853 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/querynotes],methods=[GET]}" onto public com.xintujiuzhang.aimanagement.pojo.Handwriting com.xintujiuzhang.aimanagement.controller.NotesController.querynotes(java.lang.String) 2019-08-05 10:29:20.853 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/authority/parameter_settings],methods=[GET]}" onto public java.lang.String com.xintujiuzhang.aimanagement.controller.parameterSettingsController.jumpPS(java.util.Map<java.lang.String, java.lang.Object>) 2019-08-05 10:29:20.853 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/authority/role_authorization],methods=[GET]}" onto public java.lang.String com.xintujiuzhang.aimanagement.controller.RoleAuthorizationController.jumpRA(java.util.Map<java.lang.String, java.lang.Object>) 2019-08-05 10:29:20.853 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/log/service_call],methods=[GET]}" onto public java.lang.String com.xintujiuzhang.aimanagement.controller.ServiceCallController.jumpRA(java.util.Map<java.lang.String, java.lang.Object>) 2019-08-05 10:29:20.853 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/authority/task_management],methods=[GET]}" onto public java.lang.String com.xintujiuzhang.aimanagement.controller.TaskManagementController.jumpTM(java.util.Map<java.lang.String, java.lang.Object>) 2019-08-05 10:29:20.854 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/authority/user_management]}" onto public java.lang.String com.xintujiuzhang.aimanagement.controller.UserController.jnmpUM(java.util.Map<java.lang.String, java.lang.Object>) 2019-08-05 10:29:20.854 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/queryUserInterface],methods=[GET]}" onto public java.util.Map<java.lang.String, java.lang.Object> com.xintujiuzhang.aimanagement.controller.UserInterfaceController.queryLicense(java.lang.String,java.lang.String,java.lang.Integer,java.util.Date) 2019-08-05 10:29:20.854 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/queryVersionCheckingInterface],methods=[GET]}" onto public java.util.Map<java.lang.String, java.lang.Object> com.xintujiuzhang.aimanagement.controller.VersionCheckingInterfaceController.queryVersionChecking(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.Integer,java.util.Date) 2019-08-05 10:29:20.854 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/queryVersionupdateInterface],methods=[GET]}" onto public java.util.Map<java.lang.String, java.lang.Object> com.xintujiuzhang.aimanagement.controller.VersionUpdateInterfaceController.queryVersionupdate(java.lang.String,java.lang.String,java.lang.String,java.util.Date) 2019-08-05 10:29:20.857 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest) 2019-08-05 10:29:20.857 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) 2019-08-05 10:29:20.881 INFO 7416 --- [ restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] 2019-08-05 10:29:20.881 INFO 7416 --- [ restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] 2019-08-05 10:29:20.906 INFO 7416 --- [ restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] 2019-08-05 10:29:21.115 INFO 7416 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729 2019-08-05 10:29:21.164 INFO 7416 --- [ restartedMain] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup 2019-08-05 10:29:21.165 INFO 7416 --- [ restartedMain] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'dataSource' has been autodetected for JMX exposure 2019-08-05 10:29:21.170 INFO 7416 --- [ restartedMain] o.s.j.e.a.AnnotationMBeanExporter : Located MBean 'dataSource': registering with JMX server as MBean [com.zaxxer.hikari:name=dataSource,type=HikariDataSource] 2019-08-05 10:29:21.196 INFO 7416 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path '' 2019-08-05 10:29:21.198 INFO 7416 --- [ restartedMain] com.xintujiuzhang.aimanagement.App : Started App in 8.458 seconds (JVM running for 8.828) Exception in thread "Thread-12" java.lang.RuntimeException: java.lang.NullPointerException at com.mysql.jdbc.JDBC4Connection$1$1.run(JDBC4Connection.java:106) Caused by: java.lang.NullPointerException at com.mysql.jdbc.ConnectionImpl.abortInternal(ConnectionImpl.java:1240) at com.mysql.jdbc.JDBC4Connection$1$1.run(JDBC4Connection.java:104) **在执行一些方法后“Thread-12”会不断增加** **ps:“Thread-668"**
多线程 java.lang.NullPointerException
``` Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at javax.swing.plaf.basic.BasicListUI.paintImpl(BasicListUI.java:266) at javax.swing.plaf.basic.BasicListUI.paint(BasicListUI.java:240) at javax.swing.plaf.ComponentUI.update(ComponentUI.java:161) at javax.swing.JComponent.paintComponent(JComponent.java:780) at javax.swing.JComponent.paint(JComponent.java:1056) at javax.swing.JComponent.paintToOffscreen(JComponent.java:5219) at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1572) at javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1495) at javax.swing.RepaintManager.paint(RepaintManager.java:1265) at javax.swing.JComponent._paintImmediately(JComponent.java:5167) at javax.swing.JComponent.paintImmediately(JComponent.java:4978) at javax.swing.RepaintManager$4.run(RepaintManager.java:824) at javax.swing.RepaintManager$4.run(RepaintManager.java:807) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75) at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:807) at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:782) at javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:731) at javax.swing.RepaintManager.access$1300(RepaintManager.java:64) at javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1720) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756) at java.awt.EventQueue.access$500(EventQueue.java:97) at java.awt.EventQueue$3.run(EventQueue.java:709) at java.awt.EventQueue$3.run(EventQueue.java:703) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75) at java.awt.EventQueue.dispatchEvent(EventQueue.java:726) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) at java.awt.EventDispatchThread.run(EventDispatchThread.java:82) ``` ## 我写了个socket通信的小程序,,每次启动一个客户端就创建一个线程专门用来读取Server回复的信息,主线程用来往Server发信息。 ## 有时 ,当我启动到第多个客户端时就会报出该异常,但是程序还是正常运行的。。只是在该客户端控制台输出了这些异常信息,有时一个一个关闭客户端时也会报该异常, 而这些不是我的代码里的东西,,求指导。这是异常是关于什么的。??
用swing表格获取显示MySQL数据库的信息并显示总是抛出NullPointerException异常
``` private Vector<Vector<String>> rowData; while(result.next()) { Vector<String> tempt=new Vector<String>(); tempt.add(result.getString("书名")); tempt.add(result.getString("借书时间")); tempt.add(result.getString("借阅天数")); tempt.add(result.getString("应还时间")); rowData.add(tempt); } ``` rowData.add(tempt);这句总是抛出NullPointerException异常,完全找不到头绪的 有哪位高手曾经遇到过吗??求解
Exception in thread "main" java.lang.NullPointerException
import org.apache.commons.io.FileUtils; import org.json.JSONException; import org.json.JSONObject; public class ReadJSONSample { public static void main(String[] args) throws IOException, JSONException { File file = new File(ReadJSONSample.class.getResource("/wangxiaoer.json").toString()); String content = FileUtils.readFileToString(file); JSONObject jsonObject = new JSONObject(content); System.out.println("姓名是:"+jsonObject.getString("name")); } } 控制台运行后报错 Exception in thread "main" java.lang.NullPointerException at json.ReadJSONSample.main(ReadJSONSample.java:13)
java后台向页面传输json的时候异常
页面请求数据,后台向页面传输请求到的数据,单独请求没问题。但是如果我请求的过程中另外一个用户请求则我会报异常,而后来的用户可以取到数据。。。。。。 在后台打印数据,数据从库里请求到了。前台页面是用的ajax 但是传输报错 使用的是: String msg= JSONObject.fromObject(r).toString(); response.getWriter().print(msg); 异常: 2017-06-20 15:23:11,825 [http-bio-8081-exec-2] DEBUG [org.springframework.web.servlet.DispatcherServlet] - Could not complete request java.lang.NullPointerException at org.apache.coyote.http11.InternalOutputBuffer.realWriteBytes(InternalOutputBuffer.java:215) at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:480) at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:366) at org.apache.coyote.http11.InternalOutputBuffer$OutputStreamOutputBuffer.doWrite(InternalOutputBuffer.java:240) at org.apache.coyote.http11.filters.IdentityOutputFilter.doWrite(IdentityOutputFilter.java:93) at org.apache.coyote.http11.AbstractOutputBuffer.doWrite(AbstractOutputBuffer.java:192) at org.apache.coyote.Response.doWrite(Response.java:499) at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:402) at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:480) at org.apache.catalina.connector.OutputBuffer.realWriteChars(OutputBuffer.java:485) at org.apache.tomcat.util.buf.CharChunk.flushBuffer(CharChunk.java:464) at org.apache.tomcat.util.buf.CharChunk.append(CharChunk.java:384) at org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:548) at org.apache.catalina.connector.CoyoteWriter.write(CoyoteWriter.java:174) at org.apache.catalina.connector.CoyoteWriter.write(CoyoteWriter.java:184) at org.apache.catalina.connector.CoyoteWriter.print(CoyoteWriter.java:242) at com.ruifight.custom.controller.ScreenController.indoor(ScreenController.java:155) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:178) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:442) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:430) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872) at javax.servlet.http.HttpServlet.service(HttpServlet.java:650) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) at javax.servlet.http.HttpServlet.service(HttpServlet.java:731) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:85) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745)
Java中遇到的一个异常Exception in thread "main" java.lang.NullPointerException
import java.util.*; public class NewHashTest { public static void main(String[] args) { HashMap hash = new HashMap(); Emp emp1 = new Emp("laoda","111",123f); Emp emp2 = new Emp("laoer","222",234f); Emp emp3 = new Emp("laosan","333",5466f); hash.put(111,emp1); hash.put(222,emp2); hash.put(333,emp3); if(hash.containsKey(111)) { Emp em = (Emp)hash.get(111); em.info();//可以正常显示 } Iterator iter = hash.keySet().iterator(); while(iter.hasNext()) { String key = iter.next().toString(); Emp ems = (Emp)hash.get(key); ems.info();//这里会报错 } } } class Emp { String name; String number; float slary; public void info() { System.out.println("名字叫:"+name); System.out.println("编号为:"+number); System.out.println("薪水是:"+slary); } public Emp(String name,String number,float slary) { this.name = name; this.number = number; this.slary = slary; } } 会在ems.info();一行报一个Exception in thread "main" java.lang.NullPointerException的错误,是不是传入的KEY类型有问题,还是什么别的问题,求指点。
java web java.lang.NullPointerException
严重: Servlet.service() for servlet [selectServlet] in context with path [/Exercise] threw exception java.lang.NullPointerException at DB.DataBaseConnection.selectOperation1(DataBaseConnection.java:45) at Servlet.Select.doPost(Select.java:69) at javax.servlet.http.HttpServlet.service(HttpServlet.java:646) at javax.servlet.http.HttpServlet.service(HttpServlet.java:727) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1074) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:619) 代码: public class DataBaseConnection { static String driverString="com.mysql.jdbc.Driver"; static String urlString="jdbc:mysql://localhost:3306/book"; static String username="root"; static String password="123"; public static Connection getConnection() { Connection connection; try { Class.forName(driverString); } catch (ClassNotFoundException e) { e.printStackTrace(); return null; // TODO: handle exception } try { connection=DriverManager.getConnection(urlString, username, password); } catch (SQLException e) { e.printStackTrace(); return null; // TODO: handle exception } return connection; } public static ResultSet selectOperation1(String Content,String SelectWay) { Connection connection=getConnection(); Statement statement=null; try { statement=connection.createStatement();//这一行报错。。 String sqlString="select * from bookinfo where 1=1"; if(Content!=""&&SelectWay!="") { sqlString+="and"+SelectWay+"='"+Content+"'"; } ResultSet rs=statement.executeQuery(sqlString); return rs; } catch (SQLException e) { e.printStackTrace(); return null; // TODO: handle exception } }
相见恨晚的超实用网站
搞学习 知乎:www.zhihu.com 简答题:http://www.jiandati.com/ 网易公开课:https://open.163.com/ted/ 网易云课堂:https://study.163.com/ 中国大学MOOC:www.icourse163.org 网易云课堂:study.163.com 哔哩哔哩弹幕网:www.bilibili.com 我要自学网:www.51zxw
花了20分钟,给女朋友们写了一个web版群聊程序
参考博客 [1]https://www.byteslounge.com/tutorials/java-ee-html5-websocket-example
爬虫福利二 之 妹子图网MM批量下载
爬虫福利一:27报网MM批量下载    点击 看了本文,相信大家对爬虫一定会产生强烈的兴趣,激励自己去学习爬虫,在这里提前祝:大家学有所成! 目标网站:妹子图网 环境:Python3.x 相关第三方模块:requests、beautifulsoup4 Re:各位在测试时只需要将代码里的变量 path 指定为你当前系统要保存的路径,使用 python xxx.py 或IDE运行即可。
字节跳动视频编解码面经
引言 本文主要是记录一下面试字节跳动的经历。 三四月份投了字节跳动的实习(图形图像岗位),然后hr打电话过来问了一下会不会opengl,c++,shador,当时只会一点c++,其他两个都不会,也就直接被拒了。 七月初内推了字节跳动的提前批,因为内推没有具体的岗位,hr又打电话问要不要考虑一下图形图像岗,我说实习投过这个岗位不合适,不会opengl和shador,然后hr就说秋招更看重基础。我当时
Java学习的正确打开方式
在博主认为,对于入门级学习java的最佳学习方法莫过于视频+博客+书籍+总结,前三者博主将淋漓尽致地挥毫于这篇博客文章中,至于总结在于个人,实际上越到后面你会发现学习的最好方式就是阅读参考官方文档其次就是国内的书籍,博客次之,这又是一个层次了,这里暂时不提后面再谈。博主将为各位入门java保驾护航,各位只管冲鸭!!!上天是公平的,只要不辜负时间,时间自然不会辜负你。 何谓学习?博主所理解的学习,它
程序员必须掌握的核心算法有哪些?
由于我之前一直强调数据结构以及算法学习的重要性,所以就有一些读者经常问我,数据结构与算法应该要学习到哪个程度呢?,说实话,这个问题我不知道要怎么回答你,主要取决于你想学习到哪些程度,不过针对这个问题,我稍微总结一下我学过的算法知识点,以及我觉得值得学习的算法。这些算法与数据结构的学习大多数是零散的,并没有一本把他们全部覆盖的书籍。下面是我觉得值得学习的一些算法以及数据结构,当然,我也会整理一些看过
大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了
大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...
linux系列之常用运维命令整理笔录
本博客记录工作中需要的linux运维命令,大学时候开始接触linux,会一些基本操作,可是都没有整理起来,加上是做开发,不做运维,有些命令忘记了,所以现在整理成博客,当然vi,文件操作等就不介绍了,慢慢积累一些其它拓展的命令,博客不定时更新 顺便拉下票,我在参加csdn博客之星竞选,欢迎投票支持,每个QQ或者微信每天都可以投5票,扫二维码即可,http://m234140.nofollow.ax.
比特币原理详解
一、什么是比特币 比特币是一种电子货币,是一种基于密码学的货币,在2008年11月1日由中本聪发表比特币白皮书,文中提出了一种去中心化的电子记账系统,我们平时的电子现金是银行来记账,因为银行的背后是国家信用。去中心化电子记账系统是参与者共同记账。比特币可以防止主权危机、信用风险。其好处不多做赘述,这一层面介绍的文章很多,本文主要从更深层的技术原理角度进行介绍。 二、问题引入 假设现有4个人...
Python 基础(一):入门必备知识
目录1 标识符2 关键字3 引号4 编码5 输入输出6 缩进7 多行8 注释9 数据类型10 运算符10.1 常用运算符10.2 运算符优先级 1 标识符 标识符是编程时使用的名字,用于给变量、函数、语句块等命名,Python 中标识符由字母、数字、下划线组成,不能以数字开头,区分大小写。 以下划线开头的标识符有特殊含义,单下划线开头的标识符,如:_xxx ,表示不能直接访问的类属性,需通过类提供
这30个CSS选择器,你必须熟记(上)
关注前端达人,与你共同进步CSS的魅力就是让我们前端工程师像设计师一样进行网页的设计,我们能轻而易举的改变颜色、布局、制作出漂亮的影音效果等等,我们只需要改几行代码,不需...
国产开源API网关项目进入Apache孵化器:APISIX
点击蓝色“程序猿DD”关注我回复“资源”获取独家整理的学习资料!近日,又有一个开源项目加入了这个Java开源界大名鼎鼎的Apache基金会,开始进行孵化器。项目名称:AP...
程序员接私活怎样防止做完了不给钱?
首先跟大家说明一点,我们做 IT 类的外包开发,是非标品开发,所以很有可能在开发过程中会有这样那样的需求修改,而这种需求修改很容易造成扯皮,进而影响到费用支付,甚至出现做完了项目收不到钱的情况。 那么,怎么保证自己的薪酬安全呢? 我们在开工前,一定要做好一些证据方面的准备(也就是“讨薪”的理论依据),这其中最重要的就是需求文档和验收标准。一定要让需求方提供这两个文档资料作为开发的基础。之后开发
网页实现一个简单的音乐播放器(大佬别看。(⊙﹏⊙))
今天闲着无事,就想写点东西。然后听了下歌,就打算写个播放器。 于是乎用h5 audio的加上js简单的播放器完工了。 欢迎 改进 留言。 演示地点跳到演示地点 html代码如下`&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;music&lt;/title&gt; &lt;meta charset="utf-8"&gt
Python十大装B语法
Python 是一种代表简单思想的语言,其语法相对简单,很容易上手。不过,如果就此小视 Python 语法的精妙和深邃,那就大错特错了。本文精心筛选了最能展现 Python 语法之精妙的十个知识点,并附上详细的实例代码。如能在实战中融会贯通、灵活使用,必将使代码更为精炼、高效,同时也会极大提升代码B格,使之看上去更老练,读起来更优雅。 1. for - else 什么?不是 if 和 else 才
数据库优化 - SQL优化
前面一篇文章从实例的角度进行数据库优化,通过配置一些参数让数据库性能达到最优。但是一些“不好”的SQL也会导致数据库查询变慢,影响业务流程。本文从SQL角度进行数据库优化,提升SQL运行效率。 判断问题SQL 判断SQL是否有问题时可以通过两个表象进行判断: 系统级别表象 CPU消耗严重 IO等待严重 页面响应时间过长
2019年11月中国大陆编程语言排行榜
2019年11月2日,我统计了某招聘网站,获得有效程序员招聘数据9万条。针对招聘信息,提取编程语言关键字,并统计如下: 编程语言比例 rank pl_ percentage 1 java 33.62% 2 c/c++ 16.42% 3 c_sharp 12.82% 4 javascript 12.31% 5 python 7.93% 6 go 7.25% 7
通俗易懂地给女朋友讲:线程池的内部原理
餐厅的约会 餐盘在灯光的照耀下格外晶莹洁白,女朋友拿起红酒杯轻轻地抿了一小口,对我说:“经常听你说线程池,到底线程池到底是个什么原理?”我楞了一下,心里想女朋友今天是怎么了,怎么突然问出这么专业的问题,但做为一个专业人士在女朋友面前也不能露怯啊,想了一下便说:“我先给你讲讲我前同事老王的故事吧!” 大龄程序员老王 老王是一个已经北漂十多年的程序员,岁数大了,加班加不动了,升迁也无望,于是拿着手里
经典算法(5)杨辉三角
杨辉三角 是经典算法,这篇博客对它的算法思想进行了讲解,并有完整的代码实现。
编写Spring MVC控制器的14个技巧
本期目录 1.使用@Controller构造型 2.实现控制器接口 3.扩展AbstractController类 4.为处理程序方法指定URL映射 5.为处理程序方法指定HTTP请求方法 6.将请求参数映射到处理程序方法 7.返回模型和视图 8.将对象放入模型 9.处理程序方法中的重定向 10.处理表格提交和表格验证 11.处理文件上传 12.在控制器中自动装配业务类 ...
腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹?
昨天,有网友私信我,说去阿里面试,彻底的被打击到了。问了为什么网上大量使用ThreadLocal的源码都会加上private static?他被难住了,因为他从来都没有考虑过这个问题。无独有偶,今天笔者又发现有网友吐槽了一道腾讯的面试题,我们一起来看看。 腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹? 在互联网职场论坛,一名程序员发帖求助到。二面腾讯,其中一个算法题:64匹
面试官:你连RESTful都不知道我怎么敢要你?
面试官:了解RESTful吗? 我:听说过。 面试官:那什么是RESTful? 我:就是用起来很规范,挺好的 面试官:是RESTful挺好的,还是自我感觉挺好的 我:都挺好的。 面试官:… 把门关上。 我:… 要干嘛?先关上再说。 面试官:我说出去把门关上。 我:what ?,夺门而去 文章目录01 前言02 RESTful的来源03 RESTful6大原则1. C-S架构2. 无状态3.统一的接
求小姐姐抠图竟遭白眼?痛定思痛,我决定用 Python 自力更生!
点击蓝色“Python空间”关注我丫加个“星标”,每天一起快乐的学习大家好,我是 Rocky0429,一个刚恰完午饭,正在用刷网页浪费生命的蒟蒻...一堆堆无聊八卦信息的网页内容慢慢使我的双眼模糊,一个哈欠打出了三斤老泪,就在此时我看到了一张图片:是谁!是谁把我女朋友的照片放出来的!awsl!太好看了叭...等等,那个背景上的一堆鬼画符是什么鬼?!真是看不下去!叔叔婶婶能忍,隔壁老王的三姨妈的四表...
为啥国人偏爱Mybatis,而老外喜欢Hibernate/JPA呢?
关于SQL和ORM的争论,永远都不会终止,我也一直在思考这个问题。昨天又跟群里的小伙伴进行了一番讨论,感触还是有一些,于是就有了今天这篇文。 声明:本文不会下关于Mybatis和JPA两个持久层框架哪个更好这样的结论。只是摆事实,讲道理,所以,请各位看官勿喷。 一、事件起因 关于Mybatis和JPA孰优孰劣的问题,争论已经很多年了。一直也没有结论,毕竟每个人的喜好和习惯是大不相同的。我也看
SQL-小白最佳入门sql查询一
不要偷偷的查询我的个人资料,即使你再喜欢我,也不要这样,真的不好;
项目中的if else太多了,该怎么重构?
介绍 最近跟着公司的大佬开发了一款IM系统,类似QQ和微信哈,就是聊天软件。我们有一部分业务逻辑是这样的 if (msgType = "文本") { // dosomething } else if(msgType = "图片") { // doshomething } else if(msgType = "视频") { // doshomething } else { // doshom...
致 Python 初学者
欢迎来到“Python进阶”专栏!来到这里的每一位同学,应该大致上学习了很多 Python 的基础知识,正在努力成长的过程中。在此期间,一定遇到了很多的困惑,对未来的学习方向感到迷茫。我非常理解你们所面临的处境。我从2007年开始接触 python 这门编程语言,从2009年开始单一使用 python 应对所有的开发工作,直至今天。回顾自己的学习过程,也曾经遇到过无数的困难,也曾经迷茫过、困惑过。开办这个专栏,正是为了帮助像我当年一样困惑的 Python 初学者走出困境、快速成长。希望我的经验能真正帮到你
“狗屁不通文章生成器”登顶GitHub热榜,分分钟写出万字形式主义大作
一、垃圾文字生成器介绍 最近在浏览GitHub的时候,发现了这样一个骨骼清奇的雷人项目,而且热度还特别高。 项目中文名:狗屁不通文章生成器 项目英文名:BullshitGenerator 根据作者的介绍,他是偶尔需要一些中文文字用于GUI开发时测试文本渲染,因此开发了这个废话生成器。但由于生成的废话实在是太过富于哲理,所以最近已经被小伙伴们给玩坏了。 他的文风可能是这样的: 你发现,...
程序员:我终于知道post和get的区别
是一个老生常谈的话题,然而随着不断的学习,对于以前的认识有很多误区,所以还是需要不断地总结的,学而时习之,不亦说乎
《程序人生》系列-这个程序员只用了20行代码就拿了冠军
你知道的越多,你不知道的越多 点赞再看,养成习惯GitHub上已经开源https://github.com/JavaFamily,有一线大厂面试点脑图,欢迎Star和完善 前言 这一期不算《吊打面试官》系列的,所有没前言我直接开始。 絮叨 本来应该是没有这期的,看过我上期的小伙伴应该是知道的嘛,双十一比较忙嘛,要值班又要去帮忙拍摄年会的视频素材,还得搞个程序员一天的Vlog,还要写BU...
相关热词 c#处理浮点数 c# 生成字母数字随机数 c# 动态曲线 控件 c# oracle 开发 c#选择字体大小的控件 c# usb 批量传输 c#10进制转8进制 c#转base64 c# 科学计算 c#下拉列表获取串口
立即提问

相似问题

3
java.lang.NullPointerException希望各位大佬帮帮忙,找了半天真的不晓得咋弄了
1
Error querying database. Cause: java.lang.NullPointerException
1
用swing表格获取显示MySQL数据库的信息并显示总是抛出NullPointerException异常
1
java.lang.NullPointerException--at com.alibaba.druid.pool.DruidPooledConnection.prepareStatement
2
mybatis nullpointerexception
3
求助,java在上传文档的时候出现NullPointerException
1
调用webservice报错SOAPFaultException: java.lang.NullPointerException
2
Servlet遇到java.lang.NullPointerException问题无法解决,恳求帮助
2
萌新java连接MySQL数据库出现java.lang.NullPointerException错误是为什么,求大佬看一下代码解答
4
java.lang.NullPointerException我是萌新,刚学了一点点JAVA,哪位大佬帮一下,谢谢
5
The error SQL: select * from ACT_GE_PROPERTY where NAME_ = ? Cause: java.lang.NullPointerException
4
Java的NullPointerException是什么,我如何修复它?
5
什么是 NullPointerException,怎么修复它?
3
@Autowired 报错java.lang.NullPointerException
5
Exception in thread "Thread-12" java.lang.RuntimeException: java.lang.NullPointerException
3
Java.lang.NullPointerException 在IDE中不会报错,命令行中就会报错,何解?
2
java.lang.NullPointerException异常如何解决
2
ecplise里安装javaweb插件件时出现 java.lang.NullPointerException
1
请问Exception in thread "main" java.lang.NullPointerException怎么解决,网上说的很模糊,小白不懂,谢谢大佬
0
在kettle的调试软件中执行没有问题,但是在java代码中调用就会报错,含有接口的调用。