java.lang.RuntimeException(已声明但未初始化的变量出错)

我的错误定位了,但是我不知道怎么改,请大神指点哈。
代码如下

 switch (bundle.getInt(PushConsts.CMD_ACTION)) {
 case PushConsts.GET_CLIENTID:
  comm_frame.dev.client_id = bundle.getString("clientid");  <--这里
 }

错误原因是comm_frame.dev.client_id声明了但是未初始化,但是我更改成
comm_frame.dev.client_id = null;
comm_frame.dev.client_id = bundle.getString("clientid");
还是报错,我应该怎么改它才能正常工作呢,请求指点。

错误信息如下

 07-09 19:53:49.434  30483-30483/ixz.fish_help_app E/AndroidRuntime﹕ FATAL EXCEPTION: main
    java.lang.RuntimeException: Unable to start receiver comm.GetuiReceiver: java.lang.NullPointerException
            at android.app.ActivityThread.handleReceiver(ActivityThread.java:2287)
            at android.app.ActivityThread.access$1600(ActivityThread.java:140)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1313)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:4935)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:511)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.NullPointerException
            at comm.GetuiReceiver.onReceive(GetuiReceiver.java:140)
            at android.app.ActivityThread.handleReceiver(ActivityThread.java:2280)
            at android.app.ActivityThread.access$1600(ActivityThread.java:140)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1313)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:4935)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:511)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
            at dalvik.system.NativeStart.main(Native Method)

6个回答

 comm_frame.dev.client_id中comm_frame有没有初始化,报的是空指针。所以看
 comm_frame这个对象和bundle是不是空值就行了
danielinbiti
danielinbiti 回复凌云志轩: .。。。看类定义,这么定义比较糟糕,最好用类分装起来。如果哪里都要使用,那定义成单例也行。
接近 5 年之前 回复
llx2007
凌云志轩 好像是开机动画那儿加载了一次,然后登录加载了一次
接近 5 年之前 回复
llx2007
凌云志轩 不对呀,按照我的逻辑,case PushConsts.GET_CLIENTID:这个进去一次呀,怎么进去了两次
接近 5 年之前 回复
danielinbiti
danielinbiti 回复凌云志轩: 不清楚comm_frame怎么定义的,你可以贴一下代码
接近 5 年之前 回复
llx2007
凌云志轩 饿,改过来还是不对,我去
接近 5 年之前 回复
llx2007
凌云志轩 我明白了,是它里面初始化dev的部分条件写错了,没进去
接近 5 年之前 回复
llx2007
凌云志轩 是一个数据文件呀,这个也要初始化么?
接近 5 年之前 回复
danielinbiti
danielinbiti 回复凌云志轩: 看看comm_frame什么时候初始化的,干什么用,如果是全局的,可以放在application中,如果是activity的,可以放在oncreate中初始化。看你具体用途。保证使用前初始化
接近 5 年之前 回复
llx2007
凌云志轩 是这样的,我APP运行的时候我定义了一个splash,用于替换APP开机白屏并且在加载数据时让客户看起来不糟糕,但是开机动画结束前(什么时间不定)程序就会崩溃,在进一次就好了(只要不加载动画)。是不是我的comm_frame没初始化就加载了这些信息?那我的comm_frame怎么修改呢
接近 5 年之前 回复

bundle.getString("clientid那你看看你这个bundle里有没有这个字符串代表的数据啊。
或者用Toast打印一下看看。

llx2007
凌云志轩 bundle.getString("clientid")他是有数据的
接近 5 年之前 回复
llx2007
凌云志轩 我觉得只能是comm_frame.dev.client_id了
接近 5 年之前 回复
llx2007
凌云志轩 Log.e(TAG,bundle.getString("clientid")); comm_frame.dev.client_id = bundle.getString("clientid");程序崩掉之前打印了bundle.getString("clientid")
接近 5 年之前 回复

Unable to start receiver comm.GetuiReceiver

检查AndroidManifest.xml配置文件中是否配置了receiver

llx2007
凌云志轩 我说了comm_frame.dev.client_id是他的问题,请相信我
接近 5 年之前 回复

zcomm_frame有没有初始化,是空指针

llx2007
凌云志轩 刚没看到,看到就采纳了。我的问题是应该怎么修改呢
接近 5 年之前 回复

代码太多,我嫌上一部分

 package comm;

public class comm_frame
{

    public class frame_head
    {
        public byte[] dev_id;
        public byte manu_id;
        public byte  dev_type;
        public byte frame_type;
        public short    frame_len;
    }
    static public frame_head frame_head_info;
    。。。
    里面是一些成员变量和实现函数
    }


空指针异常,看看是不是没有初始化啊

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
Servlet /claim threw load() exception java.lang.RuntimeException: 启动环境报错,如何解决?

严重: Servlet /claim threw load() exception java.lang.RuntimeException: 无法获取environmenTypeCode,请在Web应用容器启动文件中添加environmenTypeCode变量或在调用前使用setEnvironmenTypeCode方法进行环境变量初始化! at com.sinosoft.platform.ipservice.IPService.initEnvironmenTypeCode(IPService.java:462) at com.sinosoft.platform.ipservice.IPService.getIpInfoBeanByKeyAndNetType(IPService.java:429) at com.sinosoft.platform.ipservice.IpSelectAction.getIpInfoBeanByKeyAndNetType(IpSelectAction.java:86) at cn.com.cis.claim.car.wtc.WTCServlet.init(WTCServlet.java:51) at javax.servlet.GenericServlet.init(GenericServlet.java:212) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1161) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:981) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4042) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4348) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525) at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:626) at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:553) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053) at org.apache.catalina.core.StandardHost.start(StandardHost.java:719) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443) at org.apache.catalina.core.StandardService.start(StandardService.java:516) at org.apache.catalina.core.StandardServer.start(StandardServer.java:710) at org.apache.catalina.startup.Catalina.start(Catalina.java:566) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413) 2019-3-28 13:55:59 org.apache.coyote.http11.Http11Protocol start 信息: Starting Coyote HTTP/1.1 on http-8080 2019-3-28 13:55:59 org.apache.jk.common.ChannelSocket init 信息: JK: ajp13 listening on /0.0.0.0:8009 2019-3-28 13:55:59 org.apache.jk.server.JkMain start 信息: Jk running ID=0 time=0/15 config=null 2019-3-28 13:55:59 org.apache.catalina.startup.Catalina start 信息: Server startup in 55286 ms 2019-3-28 13:57:31 org.apache.coyote.http11.Http11Protocol pause 信息: Pausing Coyote HTTP/1.1 on http-8080 2019-3-28 13:57:32 org.apache.catalina.core.StandardService stop 信息: Stopping service Catalina 2019-3-28 13:57:38 org.apache.catalina.core.ApplicationContext log 信息: Closing Spring root WebApplicationContext 2019-3-28 13:57:40 org.apache.coyote.http11.Http11Protocol destroy 信息: Stopping Coyote HTTP/1.1 on http-8080 ![图片说明](https://img-ask.csdn.net/upload/201903/28/1553756397_999041.png)

java.lang.RuntimeException ,找不到配置的Action类

applicationContext.xml文件中配置scheduleAction了啊!struts.xml文件中“初始化当前用户显示所有日程列表”的action也是用的scheduleAction,为什么“查询日程列表”的action就找不到这个类呢? ---------------------- [img]http://dl.iteye.com/upload/attachment/570153/cb780579-43b0-3273-8efe-ee6ea4e7cb92.png[/img] --------------------- [img]http://dl.iteye.com/upload/attachment/570155/1cb500de-6251-3b01-bb08-28bd26c01d9d.png[/img] ---------------------- [img]http://dl.iteye.com/upload/attachment/570157/b0b8b53a-ce5a-31e4-b351-90cb8f96b835.png[/img] java.lang.RuntimeException: Invalid action class configuration that references an unknown class named [[color=red]scheduleAction[/color]] org.apache.struts2.convention.ConventionsServiceImpl.determineResultPath(ConventionsServiceImpl.java:100) org.apache.struts2.convention.ConventionUnknownHandler.determinePath(ConventionUnknownHandler.java:385) org.apache.struts2.convention.ConventionUnknownHandler.handleUnknownResult(ConventionUnknownHandler.java:274) com.opensymphony.xwork2.DefaultUnknownHandlerManager.handleUnknownResult(DefaultUnknownHandlerManager.java:76) com.opensymphony.xwork2.DefaultActionInvocation.createResult(DefaultActionInvocation.java:215) com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:356) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:266) com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:165) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:252) org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:179) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:89) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:130) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:126) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:165) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:179) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52) org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488) org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77) org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91) root cause java.lang.ClassNotFoundException: scheduleAction org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358) org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204) org.apache.struts2.util.ClassLoaderUtils.loadClass(ClassLoaderUtils.java:111) org.apache.struts2.convention.ConventionsServiceImpl.determineResultPath(ConventionsServiceImpl.java:98) org.apache.struts2.convention.ConventionUnknownHandler.determinePath(ConventionUnknownHandler.java:385) org.apache.struts2.convention.ConventionUnknownHandler.handleUnknownResult(ConventionUnknownHandler.java:274) com.opensymphony.xwork2.DefaultUnknownHandlerManager.handleUnknownResult(DefaultUnknownHandlerManager.java:76) com.opensymphony.xwork2.DefaultActionInvocation.createResult(DefaultActionInvocation.java:215) com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:356) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:266) com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:165) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:252) org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:179) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:89) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:130) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:126) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:165) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:179) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52) org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488) org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77) org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)

安卓开发 java.lang.RuntimeException: Unable to start activity ComponentInfo{(xxx)}: java.lang.NullPointerException

安卓开发实验预习,代码没有报错,虚拟机运行(API19)闪退,不知道哪里出了问题 Activity: ``` package com.example.ght201621111093_yuxi3_1; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import android.app.Activity; import android.content.Context; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; import android.os.Bundle; import android.os.Environment; import android.util.Log; import android.view.Menu; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; public class MainActivity extends Activity { SharedPreferences sp;//数据读写变量 Editor edit; //Editor编辑对象 /* 定义账户 和密码的控件变量 定义登录按钮的控件变量 */ private Button delete,saveINSIDE,saveSD,saveSP,readINSIDE,readSD,readSP; private EditText stu_name,stu_age,stu_number; // 1 定义记住密码控件变量以及文件操作变量 private File sdCardDir;//sd卡路径 private File saveFile;//文件名 private FileOutputStream outStream;//输入文件流 private FileInputStream inStream;//输入文件 @Override protected void onCreate(Bundle savedInstanceState) { delete = (Button) findViewById(R.id.delete); saveINSIDE = (Button) findViewById(R.id.saveINSIDE); saveSD = (Button) findViewById(R.id.saveSD); saveSP = (Button) findViewById(R.id.saveSP); readINSIDE = (Button) findViewById(R.id.readINSIDE); readSD = (Button) findViewById(R.id.readSD); readSP = (Button) findViewById(R.id.readSP); stu_name = (EditText) findViewById(R.id.et_name); stu_age = (EditText) findViewById(R.id.et_age); stu_number = (EditText) findViewById(R.id.et_num); super.onCreate(savedInstanceState); setContentView(R.layout.login); //利用edit()方法获取Editor对象。 edit = sp.edit(); /* 账户 和密码的控件变量赋值 登录按钮的控件变量 赋值 */ // 4 完成用户名密码的保存功能 //m_pswSave = (CheckBox) findViewById(R.id.checkBox1); // 为每一个选项设置监听 //清除 delete.setOnClickListener(new OnClickListener(){ public void onClick(View v){ stu_name.setText(""); stu_age.setText(""); stu_number.setText(""); } }); //保存内部 saveINSIDE.setOnClickListener(new OnClickListener(){ public void onClick(View v) { final String a=stu_age.getText().toString(); int a1= Integer.parseInt(a); if (a1<1||a1>100) { Toast toast = Toast.makeText(getApplicationContext(), "请输入正确的年龄", Toast.LENGTH_SHORT); toast.show(); } else { Write_Files_INSIDE("name.txt",stu_name.getText().toString()); Write_Files_INSIDE("age.txt",stu_age.getText().toString()); Write_Files_INSIDE("number.txt",stu_number.getText().toString()); } } }); //保存SD saveSD.setOnClickListener(new OnClickListener(){ public void onClick(View v) { final String a=stu_age.getText().toString(); int a1= Integer.parseInt(a); if (a1<1||a1>100) { Toast toast = Toast.makeText(getApplicationContext(), "请输入正确的年龄", Toast.LENGTH_SHORT); toast.show(); } else { Write_Files_SD("name.txt",stu_name.getText().toString()); Write_Files_SD("age.txt",stu_age.getText().toString()); Write_Files_SD("number.txt",stu_number.getText().toString()); } } }); //保存SP saveSP.setOnClickListener(new OnClickListener(){ public void onClick(View v) { final String a=stu_age.getText().toString(); int a1= Integer.parseInt(a); if (a1<1||a1>100) { Toast toast = Toast.makeText(getApplicationContext(), "请输入正确的年龄", Toast.LENGTH_SHORT); toast.show(); } else { //通过Editor对象存储key-value键值对数据 edit.putString("name",stu_name.getText().toString()); edit.putString("age",stu_age.getText().toString()); edit.putString("number",stu_number.getText().toString()); //通过commit()方法提交数据 edit.commit(); } } }); //读取INSIDE readINSIDE.setOnClickListener(new OnClickListener(){ public void onClick(View v) { if(null!=Read_Files_INSIDE("name.txt")) { stu_name.setText(Read_Files_INSIDE("name.txt")); } if(null!=Read_Files_INSIDE("age.txt")) { stu_age.setText(Read_Files_INSIDE("age.txt")); } if(null!=Read_Files_INSIDE("number.txt")) { stu_number.setText(Read_Files_INSIDE("number.txt")); } } }); //读取SD readSD.setOnClickListener(new OnClickListener(){ public void onClick(View v) { if(null!=Read_Files_INSIDE("name.txt")) { stu_name.setText(Read_Files_INSIDE("name.txt")); } if(null!=Read_Files_INSIDE("age.txt")) { stu_age.setText(Read_Files_INSIDE("age.txt")); } if(null!=Read_Files_INSIDE("number.txt")) { stu_number.setText(Read_Files_INSIDE("number.txt")); } } }); //读取SP readSP.setOnClickListener(new OnClickListener(){ public void onClick(View v) { if(null!=sp.getString("name","")) { stu_name.setText(sp.getString("name","")); } if(null!=sp.getString("age","")) { stu_age.setText(sp.getString("age","")); } if(null!=sp.getString("number","")) { stu_number.setText(sp.getString("number","")); } } }); } /* //5 INSIDE读取功能 if(null!=Read_Files_INSIDE("name.txt")) { name.setText(Read_Files_INSIDE("name.txt")); } if(null!=Read_Files_INSIDE("age.txt")) { age.setText(Read_Files_INSIDE("age.txt")); } if(null!=Read_Files_INSIDE("number.txt")) { number.setText(Read_Files_INSIDE("number.txt")); } //5 SD读取功能 if(null!=Read_Files_SD("name.txt")) { name.setText(Read_Files_SD("name.txt")); } if(null!=Read_Files_SD("age.txt")) { age.setText(Read_Files_SD("age.txt")); } if(null!=Read_Files_SD("number.txt")) { number.setText(Read_Files_SD("number.txt")); } //5 SP读取功能 if(null!=sp.getString("name","")) { name.setText(sp.getString("name","")); } if(null!=sp.getString("age","")) { age.setText(sp.getString("age","")); } if(null!=sp.getString("number","")) { number.setText(sp.getString("number","")); } */ @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } //2 INSIDE完成文件写操作功能 private void Write_Files_INSIDE(String fileName, String strContent) { try { FileOutputStream outStream=this.openFileOutput(fileName,Context.MODE_WORLD_READABLE); outStream.write(strContent.getBytes()); outStream.close(); Toast.makeText(this,"文件保存成功",Toast.LENGTH_LONG).show(); } catch (FileNotFoundException e) { return; } catch (IOException e){ return ; } } // 3 INSIDE读操作功能 private String Read_Files_INSIDE(String fileName) { try { FileInputStream inStream=this.openFileInput(fileName); ByteArrayOutputStream stream=new ByteArrayOutputStream(); byte[] buffer=new byte[1024]; int length=-1; while((length=inStream.read(buffer))!=-1) { stream.write(buffer,0,length); } stream.close(); inStream.close(); Toast.makeText(this,"文件读取成功",Toast.LENGTH_LONG).show(); return stream.toString(); } catch (FileNotFoundException e) { e.printStackTrace(); return null; } catch (IOException e){ return null; } } //2 SD文件写操作功能 private void Write_Files_SD(String fileName, String strContent) { sdCardDir = Environment.getExternalStorageDirectory(); saveFile = new File(sdCardDir, fileName); if (Environment.getExternalStorageState().equals( Environment.MEDIA_MOUNTED)) { // 创建 初始化 流对象 try { outStream = new FileOutputStream(saveFile); } catch (FileNotFoundException e) { Toast.makeText(this, "文件不存在!", Toast.LENGTH_SHORT).show(); return; } try { // 把内容写入文件 outStream.write(strContent.getBytes()); } catch (FileNotFoundException e) { // TODO Auto-generated catch block Toast.makeText(this, "文件未发现异常!", Toast.LENGTH_SHORT).show(); } catch (IOException e) { // TODO Auto-generated catch block Toast.makeText(this, "文件读写异常!", Toast.LENGTH_SHORT).show(); } catch (NullPointerException e) { Toast.makeText(this, "文件读写空指针异常!", Toast.LENGTH_SHORT).show(); } finally { try { // 关闭文件输出流 outStream.close(); } catch (IOException e) { // TODO Auto-generated catch block Toast.makeText(this, "文件读写异常!", Toast.LENGTH_SHORT).show(); } Toast.makeText(this, "文件写入成功!", Toast.LENGTH_SHORT).show(); } } else { Toast.makeText(this, "内存卡不存在!", Toast.LENGTH_SHORT).show(); return; } } // 3 SD文件读操作功能 private String Read_Files_SD(String fileName) { sdCardDir = Environment.getExternalStorageDirectory(); saveFile = new File(sdCardDir, fileName); int len; // 然后创建一个字节数组输出流 byte[] buffer = new byte[1024]; ByteArrayOutputStream ostream = new ByteArrayOutputStream(); if (Environment.getExternalStorageState().equals( Environment.MEDIA_MOUNTED)) { // 创建 初始化 流对象 try { inStream = new FileInputStream(saveFile); Log.v("Instance inStream", "实例化inStream!"); } catch (FileNotFoundException e) { Toast.makeText(this, "文件不存在!", Toast.LENGTH_SHORT).show(); return null; } try { Log.v("Read", "读数据!"); Toast.makeText(this, "文件读取成功!", Toast.LENGTH_SHORT).show(); while ((len = inStream.read(buffer)) != -1) { ostream.write(buffer, 0, len); } Log.v("Read", "读成功!"); } catch (IOException e) { Toast.makeText(this, "读 异常!", Toast.LENGTH_SHORT).show(); } try { // 最后关闭输入流和输出流 inStream.close(); ostream.close(); Log.v("Read", "读成功!"); } catch (IOException e) { Toast.makeText(this, "读 异常!", Toast.LENGTH_SHORT).show(); } String str = new String(ostream.toByteArray()); Log.v("Disp", "文本显示!"); return str; } else { Toast.makeText(this, "内存卡不存在!", Toast.LENGTH_SHORT).show(); return null; } } } ``` layout: ``` <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity" > <EditText android:id="@+id/et_name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:ems="10" /> <Button android:id="@+id/saveINSIDE" android:layout_width="135dp" android:layout_height="50dp" android:layout_alignLeft="@+id/delete" android:layout_below="@+id/delete" android:layout_marginTop="21dp" android:text="保存内部" /> <Button android:id="@+id/saveSD" android:layout_width="135dp" android:layout_height="50dp" android:layout_alignLeft="@+id/saveINSIDE" android:layout_below="@+id/saveINSIDE" android:layout_marginTop="18dp" android:text="保存SD" /> <Button android:id="@+id/saveSP" android:layout_width="135dp" android:layout_height="50dp" android:layout_alignLeft="@+id/saveSD" android:layout_below="@+id/saveSD" android:layout_marginTop="22dp" android:text="保存SP" /> <Button android:id="@+id/readINSIDE" android:layout_width="135dp" android:layout_height="50dp" android:layout_alignBottom="@+id/saveINSIDE" android:layout_alignRight="@+id/et_age" android:text="读取内部" /> <Button android:id="@+id/readSD" android:layout_width="135dp" android:layout_height="50dp" android:layout_alignBaseline="@+id/saveSD" android:layout_alignBottom="@+id/saveSD" android:layout_alignLeft="@+id/readINSIDE" android:text="读取SD" /> <Button android:id="@+id/readSP" android:layout_width="135dp" android:layout_height="50dp" android:layout_alignBaseline="@+id/saveSP" android:layout_alignBottom="@+id/saveSP" android:layout_alignRight="@+id/readSD" android:text="读取SP" /> <TextView android:id="@+id/age" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@+id/delete" android:layout_below="@+id/name" android:layout_marginTop="34dp" android:text="年龄:" /> <EditText android:id="@+id/et_age" android:layout_width="wrap_content" android:inputType="number" android:layout_height="wrap_content" android:layout_alignBottom="@+id/age" android:layout_alignLeft="@+id/et_name" android:ems="10" /> <EditText android:id="@+id/et_num" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@+id/et_age" android:layout_below="@+id/et_age" android:layout_marginTop="18dp" android:ems="10" /> <TextView android:id="@+id/number" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBottom="@+id/et_num" android:layout_alignLeft="@+id/age" android:text="学号:" /> <TextView android:id="@+id/name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBottom="@+id/et_name" android:layout_alignLeft="@+id/age" android:text="姓名:" /> <Button android:id="@+id/delete" android:layout_width="135dp" android:layout_height="50dp" android:layout_below="@+id/et_num" android:layout_marginTop="17dp" android:text="清除" /> </RelativeLayout> ``` Logcat: ``` 04-07 13:23:38.877: W/dalvikvm(1340): threadid=1: thread exiting with uncaught exception (group=0xb3a77b90) 04-07 13:23:38.887: E/AndroidRuntime(1340): FATAL EXCEPTION: main 04-07 13:23:38.887: E/AndroidRuntime(1340): Process: com.example.ght201621111093_yuxi3_1, PID: 1340 04-07 13:23:38.887: E/AndroidRuntime(1340): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.ght201621111093_yuxi3_1/com.example.ght201621111093_yuxi3_1.MainActivity}: java.lang.NullPointerException 04-07 13:23:38.887: E/AndroidRuntime(1340): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2176) 04-07 13:23:38.887: E/AndroidRuntime(1340): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2226) 04-07 13:23:38.887: E/AndroidRuntime(1340): at android.app.ActivityThread.access$700(ActivityThread.java:135) 04-07 13:23:38.887: E/AndroidRuntime(1340): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1397) 04-07 13:23:38.887: E/AndroidRuntime(1340): at android.os.Handler.dispatchMessage(Handler.java:102) 04-07 13:23:38.887: E/AndroidRuntime(1340): at android.os.Looper.loop(Looper.java:137) 04-07 13:23:38.887: E/AndroidRuntime(1340): at android.app.ActivityThread.main(ActivityThread.java:4998) 04-07 13:23:38.887: E/AndroidRuntime(1340): at java.lang.reflect.Method.invokeNative(Native Method) 04-07 13:23:38.887: E/AndroidRuntime(1340): at java.lang.reflect.Method.invoke(Method.java:515) 04-07 13:23:38.887: E/AndroidRuntime(1340): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777) 04-07 13:23:38.887: E/AndroidRuntime(1340): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593) 04-07 13:23:38.887: E/AndroidRuntime(1340): at dalvik.system.NativeStart.main(Native Method) 04-07 13:23:38.887: E/AndroidRuntime(1340): Caused by: java.lang.NullPointerException 04-07 13:23:38.887: E/AndroidRuntime(1340): at com.example.ght201621111093_yuxi3_1.MainActivity.onCreate(MainActivity.java:57) 04-07 13:23:38.887: E/AndroidRuntime(1340): at android.app.Activity.performCreate(Activity.java:5243) 04-07 13:23:38.887: E/AndroidRuntime(1340): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 04-07 13:23:38.887: E/AndroidRuntime(1340): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2140) 04-07 13:23:38.887: E/AndroidRuntime(1340): ... 11 more ```

安卓开发中java.lang.RuntimeException: Unable to start activity ComponentInfo问题

package com.example.test; import android.app.ActivityGroup; import android.app.LocalActivityManager; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; @SuppressWarnings("deprecation") public class MainActivity extends ActivityGroup { // Tab Activity Layout private LocalActivityManager localActivityManager = null; private LinearLayout mainTabContainer = null; private Intent mainTabIntent = null; // Tab banner title private TextView mainTabTitleTextView = null; // Tab ImageView private ImageView appreciateImageView = null; private ImageView discussImageView = null; private ImageView identificationImageView = null; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); appreciateImageView = (ImageView) super .findViewById(R.id.appreciate_tab_btn); mainTabContainer = (LinearLayout) findViewById(R.id.main_tab_banner_title); appreciateImageView.setImageResource(R.drawable.appreciate_press); discussImageView.setImageResource(R.drawable.discuss_normal); identificationImageView .setImageResource(R.drawable.identification_normal); localActivityManager = getLocalActivityManager(); mainTabTitleTextView = (TextView) findViewById(R.id.main_tab_banner_title); appreciateImageView = (ImageView) findViewById(R.id.appreciate_tab_btn); discussImageView = (ImageView) findViewById(R.id.discuss_tab_btn); identificationImageView = (ImageView) findViewById(R.id.identification_tab_btn); setContainerView("appreciate", AppreciateTabActivity.class); setContentView(R.layout.activity_main); initTab(); } /** * 初始化Tab项 */ private void initTab() { mainTabTitleTextView = (TextView) findViewById(R.id.main_tab_banner_title); appreciateImageView = (ImageView) findViewById(R.id.appreciate_tab_btn); discussImageView = (ImageView) findViewById(R.id.discuss_tab_btn); identificationImageView = (ImageView) findViewById(R.id.identification_tab_btn); appreciateImageView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { appreciateImageView .setImageResource(R.drawable.appreciate_press); discussImageView.setImageResource(R.drawable.discuss_normal); identificationImageView .setImageResource(R.drawable.identification_normal); setContainerView("appreciate", AppreciateTabActivity.class); mainTabTitleTextView.setText("欣赏美花"); } }); discussImageView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { appreciateImageView .setImageResource(R.drawable.appreciate_normal); discussImageView.setImageResource(R.drawable.discuss_press); identificationImageView .setImageResource(R.drawable.identification_normal); setContainerView("discuss", DiscussTabActivity.class); mainTabTitleTextView.setText("评花论花"); } }); identificationImageView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { appreciateImageView .setImageResource(R.drawable.appreciate_normal); discussImageView.setImageResource(R.drawable.discuss_normal); identificationImageView .setImageResource(R.drawable.identification_press); setContainerView("identification", IdentificationTabActivity.class); mainTabTitleTextView.setText("亮眼识花"); } }); } public void setContainerView(String id, Class<?> activity) { mainTabContainer.removeAllViews(); mainTabIntent = new Intent(this, activity); mainTabContainer.addView(localActivityManager.startActivity(id, mainTabIntent).getDecorView()); } } 出现如下错误:![CSDN移动问答][1] [1]: http://xiangce.baidu.com/picture/detail/a3296cfaddcb74077c4b6751e000a41f08316fc6?from=dialoghttp://xiangce.baidu.com/picture/detail/a3296cfaddcb74077c4b6751e000a41f08316fc6?from=dialog

java.lang.ClassNotFoundException问题

java.lang.ClassNotFoundException: com.xx.listener.InitialListener at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3770) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4334) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920) at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053) at org.apache.catalina.core.StandardHost.start(StandardHost.java:719) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443) at org.apache.catalina.core.StandardService.start(StandardService.java:516) at org.apache.catalina.core.StandardServer.start(StandardServer.java:710) at org.apache.catalina.startup.Catalina.start(Catalina.java:566) 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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413) web.xml中 <listener> <display-name>InitialListener</display-name> <listener-class> com.xx.listener.InitialListener </listener-class> </listener> 类: public class InitialListener implements ServletContextListener { private static final long serialVersionUID = 1L; private static final Log log = LogFactory.getLog(InitialListener.class); //系统基本设置业务对象 private static final ISystemConfigService systemConfigService = (ISystemConfigService)SpringUtil.getObjectFromSpring("systemConfigService"); public void contextDestroyed(ServletContextEvent sce) { log.info("销毁系统监听器初始化参数"); } public void contextInitialized(ServletContextEvent event) { log.info("初始化系统参数开始..."); ServletContext application = event.getServletContext(); //网站页面 String domainName = application.getInitParameter("domainName"); //页面没有检索到相关数据时,显示的提示信息 String noDataMessage = application.getInitParameter("noDataMessage"); application.setAttribute("noDataMessage", noDataMessage); application.setAttribute("baseUrl", domainName); application.setAttribute("siteUrl", "www." + domainName); //application.setAttribute("groupUrl", "www." + domainName); application.setAttribute("groupUrl", "http://211.149.196.53:30000"); //全局上下文路径 application.setAttribute("contextPath", application.getContextPath()); application.setAttribute("fileBasePath", event.getServletContext().getRealPath("/")); application.setAttribute("fileDirectory", "temp"); application.setAttribute("separator", File.separator); //获取网站设置的基本对象 SystemConfig systemConfig = null; try { systemConfig = systemConfigService.querySystemConfig(); if(systemConfig != null) { application.setAttribute(ContextConstants.SCOPE_SYSTEM_SETTING, systemConfig); } } catch(Exception e){ log.info("初始化系统基本设置对象的时候出错: " + e.fillInStackTrace()); } application.setAttribute("UPLOAD_SEPARATOR_VALUE", ContextConstants.UPLOAD_SEPARATOR_VALUE); log.info("初始化系统参数结束..."); } }

java.lang.IllegalStateException:

在启动tomcat服务的时候报错 严重: Exception sending context destroyed event to listener instance of class org.springframework.web.context.ContextLoaderListener java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext at org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory(AbstractRefreshableApplicationContext.java:170) at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:908) at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:884) at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:836) at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:579) at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:115) at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4980) at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5626) at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:744) 网上有说是ApplicationContext ctx = new ClassPathXmlApplicationContext();是这样写导致的,但是我没写过这种方式, 还有说是@Controller重名的问题 但是好像也不是, 请各位大神帮忙看看 web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:javaee="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" id="WebApp_ID" version="2.4"> <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list> <!-- spring的监听器 --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:application-context.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!-- log4j --> <context-param> <param-name>log4jConfigLocation</param-name> <param-value>classpath:/properties/log4j.properties</param-value> </context-param> <listener> <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class> </listener> <!-- 中文过滤器 --> <filter> <filter-name>encoding</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> <init-param> <!--强制转换编码(request和response均适用) --> <param-name>ForceEncoding</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>encoding</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- springmvc 配置 --> <servlet> <servlet-name>amall</servlet-name> <servlet-class>com.amall.core.security.filter.AmallDispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:springmvc-servlet.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>amall</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> </web-app>

hadoop hive 初始化报错

环境:centos7 hadoop3.1.2 hive2.3.0 [root@hadoop metastore]# schematool -initSchema -dbType mysql Exception in thread "main" java.lang.ClassNotFoundException: org.apache.hive.beeline.HiveSchemaTool at java.net.URLClassLoader.findClass(URLClassLoader.java:382) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:348) at org.apache.hadoop.util.RunJar.run(RunJar.java:311) at org.apache.hadoop.util.RunJar.main(RunJar.java:232) [root@hadoop metastore]# hive which: no hbase in (/root/mysql/apache-hive-2.3.0-bin/bin:/root/train/hadoop-3.1.2/sbin:/root/train/hadoop-3.1.2/bin:/root/train/jdk1.8.0_211/bin:/root/train/hive/bin:/root/train/hadoop-3.1.2/sbin:/root/train/hadoop-3.1.2/bin:/root/train/jdk1.8.0_211/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin) Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/hive/ql/CommandNeedRetryException at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:348) at org.apache.hadoop.util.RunJar.run(RunJar.java:311) at org.apache.hadoop.util.RunJar.main(RunJar.java:232) Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.hive.ql.CommandNeedRetryException at java.net.URLClassLoader.findClass(URLClassLoader.java:382) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 4 more Navicat Premium 都能成功登入mysql建立的hive数据库 hive 配置文件都没问题 mysql连接器也放入了lib

Java+ArcObject运行出错 initializeVisualBeans

说明:64位 Win7系统,eclipse是32位,JDK 是32位 本人初次接触 ARCObject JDK for Java,对Java有一定的了解,在eclipse中运行自带示例时,出现以下错误,请知道问题的给予指导,谢谢! Could not load native libraries.java.lang.UnsatisfiedLinkError: no ntvinv in java.library.path java.lang.UnsatisfiedLinkError: no ntvinv in java.library.path at java.lang.ClassLoader.loadLibrary(Unknown Source) at java.lang.Runtime.loadLibrary0(Unknown Source) at java.lang.System.loadLibrary(Unknown Source) at com.esri.arcgis.interop.NativeLoader.loadLibrary(Unknown Source) at com.esri.arcgis.system.EngineInitializer.initializeVisualBeans(Unknown Source) at arcgissamples.mapbean.AddLayerFileToMap.main(AddLayerFileToMap.java:322) Exception in thread "ArcGIS VisualBean Mode STA Thread" java.lang.UnsatisfiedLinkError: com.esri.arcgis.interop.NativeObjRef.runMessagePump()V at com.esri.arcgis.interop.NativeObjRef.runMessagePump(Native Method) at com.esri.arcgis.interop.STAThread.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Could not load native libraries. java.lang.UnsatisfiedLinkError: no ntvinv in java.library.path java.lang.UnsatisfiedLinkError: no ntvinv in java.library.path at java.lang.ClassLoader.loadLibrary(Unknown Source) at java.lang.Runtime.loadLibrary0(Unknown Source) at java.lang.System.loadLibrary(Unknown Source) at com.esri.arcgis.interop.NativeLoader.loadLibrary(Unknown Source) at com.esri.arcgis.interop.NativeObjRef.p(Unknown Source) at com.esri.arcgis.interop.Dispatch.a(Unknown Source) at com.esri.arcgis.interop.Dispatch.isNativeMode(Unknown Source) at com.esri.arcgis.interop.Dispatch.createDispatch(Unknown Source) at com.esri.arcgis.interop.Dispatch.<init>(Unknown Source) at com.esri.arcgis.version.IArcGISVersionProxy.<init>(Unknown Source) at com.esri.arcgis.version.VersionManager.<init>(Unknown Source) at com.esri.arcgis.version.VersionManager.<init>(Unknown Source) at com.esri.arcgis.system.EngineInitializer.setVersionAndInitialize(Unknown Source) at com.esri.arcgis.system.EngineInitializer.initializeVisualBeans(Unknown Source) at arcgissamples.mapbean.AddLayerFileToMap.main(AddLayerFileToMap.java:322) java.lang.RuntimeException: Failed to initialize native code invocation: null at com.esri.arcgis.interop.NativeObjRef.p(Unknown Source) at com.esri.arcgis.interop.Dispatch.a(Unknown Source) at com.esri.arcgis.interop.Dispatch.isNativeMode(Unknown Source) at com.esri.arcgis.interop.Dispatch.createDispatch(Unknown Source) at com.esri.arcgis.interop.Dispatch.<init>(Unknown Source) at com.esri.arcgis.version.IArcGISVersionProxy.<init>(Unknown Source) at com.esri.arcgis.version.VersionManager.<init>(Unknown Source) at com.esri.arcgis.version.VersionManager.<init>(Unknown Source) at com.esri.arcgis.system.EngineInitializer.setVersionAndInitialize(Unknown Source) at com.esri.arcgis.system.EngineInitializer.initializeVisualBeans(Unknown Source) at arcgissamples.mapbean.AddLayerFileToMap.main(AddLayerFileToMap.java:322) Error in sample application: Can not use native code: Initialisation failed java.lang.RuntimeException: Can not use native code: Initialisation failed at com.esri.arcgis.interop.NativeObjRef.<init>(Unknown Source) at com.esri.arcgis.interop.Dispatch.createDispatch(Unknown Source) at com.esri.arcgis.interop.Dispatch.<init>(Unknown Source) at com.esri.arcgis.version.IArcGISVersionProxy.<init>(Unknown Source) at com.esri.arcgis.version.VersionManager.<init>(Unknown Source) at com.esri.arcgis.version.VersionManager.<init>(Unknown Source) at com.esri.arcgis.system.EngineInitializer.setVersionAndInitialize(Unknown Source) at com.esri.arcgis.system.EngineInitializer.initializeVisualBeans(Unknown Source) at arcgissamples.mapbean.AddLayerFileToMap.main(AddLayerFileToMap.java:322) Exiting ... 请各位知道的兄弟指点。

hadoop使用yarn运行jar 报java.lang.ClassNotFoundException 找不到类 (找不到的不是主类)

1、写了一个数据分析的程序,用idea打成jar包,依赖jar都打进去了 ![图片说明](https://img-ask.csdn.net/upload/201911/03/1572779664_439750.png) 已经设置了 job.setJarByClass(CountDurationRunner.class); 2、开启hadoop zookeeper 和hbase集群 3、yarn运行jar : $ /opt/module/hadoop-2.7.2/bin/yarn jar ct_analysis.jar runner.CountDurationRunner 报错截图:![图片说明](https://img-ask.csdn.net/upload/201911/03/1572779908_781957.png) CountDurationRunner类代码: ``` package runner; import kv.key.ComDimension; //就是这里第一个就没找到 import kv.value.CountDurationValue; import mapper.CountDurationMapper; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.client.Admin; import org.apache.hadoop.hbase.client.Connection; import org.apache.hadoop.hbase.client.ConnectionFactory; import org.apache.hadoop.hbase.client.Scan; import org.apache.hadoop.hbase.mapreduce.TableMapReduceUtil; import org.apache.hadoop.io.Text; import org.apache.hadoop.mapreduce.Job; import org.apache.hadoop.util.Tool; import org.apache.hadoop.util.ToolRunner; import outputformat.MysqlOutputFormat; import reducer.CountDurationReducer; import java.io.IOException; public class CountDurationRunner implements Tool { private Configuration conf = null; @Override public void setConf(Configuration conf) { this.conf = HBaseConfiguration.create(conf); } @Override public Configuration getConf() { return this.conf; } @Override public int run(String[] args) throws Exception { //得到conf Configuration conf = this.getConf(); //实例化job Job job = Job.getInstance(conf); job.setJarByClass(CountDurationRunner.class); //组装Mapper InputFormat initHbaseInputConfig(job); //组装Reducer outputFormat initHbaseOutputConfig(job); return job.waitForCompletion(true) ? 0 : 1; } private void initHbaseOutputConfig(Job job) { Connection connection = null; Admin admin = null; String tableName = "ns_ct:calllog"; try { connection = ConnectionFactory.createConnection(job.getConfiguration()); admin = connection.getAdmin(); if(!admin.tableExists(TableName.valueOf(tableName))) throw new RuntimeException("没有找到目标表"); Scan scan = new Scan(); //初始化Mapper TableMapReduceUtil.initTableMapperJob( tableName, scan, CountDurationMapper.class, ComDimension.class, Text.class, job, true); }catch (IOException e){ e.printStackTrace(); }finally { try { if(admin!=null) admin.close(); if(connection!=null) connection.close(); } catch (IOException e) { e.printStackTrace(); } } } private void initHbaseInputConfig(Job job) { job.setReducerClass(CountDurationReducer.class); job.setOutputKeyClass(ComDimension.class); job.setOutputValueClass(CountDurationValue.class); job.setOutputFormatClass(MysqlOutputFormat.class); } public static void main(String[] args) { try { int status = ToolRunner.run(new CountDurationRunner(), args); System.exit(status); } catch (Exception e) { e.printStackTrace(); } } } 这问题困扰很久了,有人说classPath不对,不知道如何修改,求助! ```

已经熬了两个通宵了,求大神指教

Exception in thread "main" java.lang.ExceptionInInitializerError at biz.UserBiz.addNewUser(UserBiz.java:24) at test.Test.main(Test.java:20) Caused by: java.lang.RuntimeException: Hibernate初始化失败 at commom.HibernateSessionFaction.<clinit>(HibernateSessionFaction.java:24) ... 2 more Caused by: org.hibernate.MappingException: invalid configuration at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2241) at org.hibernate.cfg.Configuration.configure(Configuration.java:2158) at org.hibernate.cfg.Configuration.configure(Configuration.java:2137) at commom.HibernateSessionFaction.<clinit>(HibernateSessionFaction.java:20) ... 2 more Caused by: org.xml.sax.SAXParseException: Document root element "hiberbate-configuration", must match DOCTYPE root "hibernate-configuration". at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)

Hadoop2.x ,一直报无法初始化对象,这个是什么原因啊

15/07/25 03:54:19 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable 15/07/25 03:54:31 INFO client.RMProxy: Connecting to ResourceManager at /0.0.0.0:8032 15/07/25 03:54:32 WARN mapreduce.JobSubmitter: Hadoop command-line option parsing not performed. Implement the Tool interface and execute your application with ToolRunner to remedy this. 15/07/25 03:54:32 INFO mapreduce.JobSubmitter: Cleaning up the staging area /tmp/hadoop-yarn/staging/root/.staging/job_1437805442648_0002 Exception in thread "main" java.lang.RuntimeException: java.lang.InstantiationException at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:131) at org.apache.hadoop.mapreduce.JobSubmitter.writeNewSplits(JobSubmitter.java:594) at org.apache.hadoop.mapreduce.JobSubmitter.writeSplits(JobSubmitter.java:614) at org.apache.hadoop.mapreduce.JobSubmitter.submitJobInternal(JobSubmitter.java:492) at org.apache.hadoop.mapreduce.Job$10.run(Job.java:1296) at org.apache.hadoop.mapreduce.Job$10.run(Job.java:1293) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAs(Subject.java:415) at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1628) at org.apache.hadoop.mapreduce.Job.submit(Job.java:1293) at org.apache.hadoop.mapreduce.Job.waitForCompletion(Job.java:1314) at com.baizhi.myhadoop.TestCombineFileInputFormat.main(TestCombineFileInputFormat.java:66) 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.apache.hadoop.util.RunJar.run(RunJar.java:221) at org.apache.hadoop.util.RunJar.main(RunJar.java:136) Caused by: java.lang.InstantiationException at sun.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(InstantiationExceptionConstructorAccessorImpl.java:48) at java.lang.reflect.Constructor.newInstance(Constructor.java:526) at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:129) ... 17 more

android 自定义键盘报错

android.inputmethodservice.KeyboardView用这个自定义键盘,有时回出现如下错误,求解: ava.lang.RuntimeException: InputChannel is not initialized. at android.view.InputEventReceiver.nativeInit(Native Method) at android.view.InputEventReceiver.(InputEventReceiver.java:70) at android.view.ViewRootImpl$WindowInputEventReceiver.(ViewRootImpl.java:5646) at android.view.ViewRootImpl.setView(ViewRootImpl.java:609) at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:259) at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2844) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2244) at android.app.ActivityThread.access$800(ActivityThread.java:141) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1202) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5047) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:806) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622) at dalvik.system.NativeStart.main(Native Method)

JavaFX代码运行之后报错找不到或无法加载主类?

出现报错 错误: 找不到或无法加载主类 com.Test.MyJavaFX 原因: java.lang.NoClassDefFoundError: javafx/application/Application 附上代码 package com.Test; import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.stage.Stage; public class MyJavaFX extends Application{ @Override public void start(Stage primaryStage) { Button btOK = new Button("OK"); Scene scene = new Scene(btOK, 200, 250); primaryStage.setTitle("MyJavaFX"); primaryStage.setScene(scene); primaryStage.show(); } public static void main(String[] args) { Application.launch(args); } }

webservice 配置cxf总是报错

ERROR 2015-10-21 11:16:39,846 [main] org.springframework.web.servlet.DispatcherServlet: Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'wobroadbandser': Invocation of init method failed; nested exception is javax.xml.ws.WebServiceException: java.lang.RuntimeException: Soap 1.1 endpoint already registered on address /WoBroadbandSerSOAP at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1482) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:626) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479) at org.apache.cxf.transport.servlet.CXFServlet.loadAdditionalConfig(CXFServlet.java:190) at org.apache.cxf.transport.servlet.CXFServlet.updateContext(CXFServlet.java:158) at org.apache.cxf.transport.servlet.CXFServlet.onApplicationEvent(CXFServlet.java:206) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:96) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:334) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:336) at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:948) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482) at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:651) at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:599) at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:665) at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:518) at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:459) at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136) at javax.servlet.GenericServlet.init(GenericServlet.java:212) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1213) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1026) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4425) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4738) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:802) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:583) at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:676) at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:602) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:503) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1322) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:325) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1068) at org.apache.catalina.core.StandardHost.start(StandardHost.java:822) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1060) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463) at org.apache.catalina.core.StandardService.start(StandardService.java:525) at org.apache.catalina.core.StandardServer.start(StandardServer.java:759) at org.apache.catalina.startup.Catalina.start(Catalina.java:595) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)

struts环境搭建出现问题

web.xml ``` <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" metadata-complete="true" version="3.1"> <filter> <filter-name>struts</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <filter-mapping> <filter-name>struts</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app> ``` struts.xml ``` <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN" "http://struts.apache.org/dtds/struts-2.3.dtd"> <struts> <package name="hello" extends = "struts-default"> <action name="hello" class="Action.HelloAction"> <result name = "success">/index.jsp</result> </action> </package> </struts> ``` action类 ``` **package action; public class HelloAction { public String execute(){ System.out.println("hello struts2"); return "success"; } } ``` 错误提示: ERROR org.apache.struts2.dispatcher.Dispatcher - Dispatcher initialization failed java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException 后面还有一些列错误,包括 无法初始化filter什么的一系列,问题描述看起来特别像jar包没有正确导入,但是我从官网上下的,原封不动的导入进入lib,为了怕官方jar包错误,我还特意把空项目war解压下来在lib中找到ar包导入,可是还是出问题,用的服务器是tomcat,特来求解 头都大了,查了好多资料,都不是我遇到的情况,求大大们看一下,才开始学习struts不久,用的myeclipse blue edition,头疼。。。

求JBoss大神帮忙,springBoot项目,部署tomcat没问题。部署jboss就报错

jdk1.8 jboss-eap-7.2 报错信息: ![图片说明](https://img-ask.csdn.net/upload/202005/14/1589443851_835180.png) ``` 2020-05-14 15:28:50,968 INFO [tk.mybatis.mapper.autoconfigure.MapperCacheDisabler] (ServerService Thread Pool -- 87) Clear tk.mybatis.mapper.version.VersionUtil CACHE cache. 2020-05-14 15:28:50,968 INFO [tk.mybatis.mapper.autoconfigure.MapperCacheDisabler] (ServerService Thread Pool -- 87) Clear EntityHelper entityTableMap cache. 2020-05-14 15:28:51,372 INFO [org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler] (ServerService Thread Pool -- 87) Initializing ExecutorService 'taskScheduler' 2020-05-14 15:28:51,594 INFO [org.springframework.integration.endpoint.EventDrivenConsumer] (ServerService Thread Pool -- 87) Adding {logging-channel-adapter:_org.springframework.integration.errorLogger} as a subscriber to the 'errorChannel' channel 2020-05-14 15:28:51,594 INFO [org.springframework.integration.channel.PublishSubscribeChannel] (ServerService Thread Pool -- 87) Channel 'application.errorChannel' has 1 subscriber(s). 2020-05-14 15:28:51,597 INFO [org.springframework.integration.endpoint.EventDrivenConsumer] (ServerService Thread Pool -- 87) started _org.springframework.integration.errorLogger 2020-05-14 15:28:51,599 INFO [org.springframework.scheduling.quartz.SchedulerFactoryBean] (ServerService Thread Pool -- 87) Starting Quartz Scheduler now 2020-05-14 15:28:51,663 INFO [org.springframework.scheduling.quartz.LocalDataSourceJobStore] (ServerService Thread Pool -- 87) ClusterManager: detected 1 failed or restarted instances. 2020-05-14 15:28:51,663 INFO [org.springframework.scheduling.quartz.LocalDataSourceJobStore] (ServerService Thread Pool -- 87) ClusterManager: Scanning for instance "DESKTOP-C8VU1M31589441150514"'s failed in-progress jobs. 2020-05-14 15:28:51,705 INFO [org.quartz.core.QuartzScheduler] (ServerService Thread Pool -- 87) Scheduler schedulerFactoryBean_$_DESKTOP-C8VU1M31589441328257 started. 2020-05-14 15:28:51,725 INFO [com.travelsky.ServletInitializer] (ServerService Thread Pool -- 87) Started ServletInitializer in 9.172 seconds (JVM running for 29.237) 2020-05-14 15:28:51,767 INFO [javax.enterprise.resource.webcontainer.jsf.config] (ServerService Thread Pool -- 87) 初始化上下文 '/cscm' 的 Mojarra 2.3.5.SP2-redhat-00001 2020-05-14 15:28:58,000 SEVERE [javax.enterprise.resource.webcontainer.jsf.config] (ServerService Thread Pool -- 87) Critical error during deployment: : java.lang.NullPointerException at javax.el.CompositeELResolver.add(CompositeELResolver.java:117) at com.sun.faces.el.DemuxCompositeELResolver.addRootELResolver(DemuxCompositeELResolver.java:142) at com.sun.faces.el.ELUtils.addEL3_0_Resolvers(ELUtils.java:336) at com.sun.faces.el.ELUtils.buildFacesResolver(ELUtils.java:258) at com.sun.faces.application.ApplicationAssociate.initializeELResolverChains(ApplicationAssociate.java:503) at com.sun.faces.application.ApplicationImpl.performOneTimeELInitialization(ApplicationImpl.java:1405) at com.sun.faces.application.ApplicationImpl.getELResolver(ApplicationImpl.java:529) at javax.faces.application.ApplicationWrapper.getELResolver(ApplicationWrapper.java:621) at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:256) at io.undertow.servlet.core.ApplicationListeners.contextInitialized(ApplicationListeners.java:187) at io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:216) at io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:185) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105) at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502) at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502) at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502) at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502) at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:250) at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:96) at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:78) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1985) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1487) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1378) at java.lang.Thread.run(Thread.java:748) at org.jboss.threads.JBossThread.run(JBossThread.java:485) 2020-05-14 15:28:58,004 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 87) MSC000001: Failed to start service jboss.deployment.unit."cscm.war".undertow-deployment: org.jboss.msc.service.StartException in service jboss.deployment.unit."cscm.war".undertow-deployment: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.NullPointerException at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:81) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1985) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1487) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1378) at java.lang.Thread.run(Thread.java:748) at org.jboss.threads.JBossThread.run(JBossThread.java:485) Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.NullPointerException at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:252) at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:96) at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:78) ... 8 more Caused by: java.lang.RuntimeException: java.lang.NullPointerException at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:315) at io.undertow.servlet.core.ApplicationListeners.contextInitialized(ApplicationListeners.java:187) at io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:216) at io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:185) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105) at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502) at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502) at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502) at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502) at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:250) ... 10 more Caused by: java.lang.NullPointerException at javax.el.CompositeELResolver.add(CompositeELResolver.java:117) at com.sun.faces.el.DemuxCompositeELResolver.addRootELResolver(DemuxCompositeELResolver.java:142) at com.sun.faces.el.ELUtils.addEL3_0_Resolvers(ELUtils.java:336) at com.sun.faces.el.ELUtils.buildFacesResolver(ELUtils.java:258) at com.sun.faces.application.ApplicationAssociate.initializeELResolverChains(ApplicationAssociate.java:503) at com.sun.faces.application.ApplicationImpl.performOneTimeELInitialization(ApplicationImpl.java:1405) at com.sun.faces.application.ApplicationImpl.getELResolver(ApplicationImpl.java:529) at javax.faces.application.ApplicationWrapper.getELResolver(ApplicationWrapper.java:621) at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:256) ... 21 more 2020-05-14 15:28:58,011 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: 操作("deploy") 失败 -- 地址:([("deployment" => "cscm.war")])-- 失败操作:{"WFLYCTL0080: 失败的服务" => {"jboss.deployment.unit.\"cscm.war\".undertow-deployment" => "java.lang.RuntimeException: java.lang.RuntimeException: java.lang.NullPointerException Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.NullPointerException Caused by: java.lang.RuntimeException: java.lang.NullPointerException Caused by: java.lang.NullPointerException"}} 2020-05-14 15:28:58,019 INFO [org.jboss.as.server] (ServerService Thread Pool -- 42) WFLYSRV0010: 已部署的 "cscm.war"(runtime-name: "cscm.war") 2020-05-14 15:28:58,020 INFO [org.jboss.as.controller] (Controller Boot Thread) WFLYCTL0183: 服务状态报告 WFLYCTL0186: 启动失败的服务: service jboss.deployment.unit."cscm.war".undertow-deployment: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.NullPointerException 2020-05-14 15:28:58,058 INFO [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0212: 恢复服务器 2020-05-14 15:28:58,060 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: 侦听 http://0.0.0.0:9990/management 的 HTTP 管理接口 2020-05-14 15:28:58,060 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: 管理控制台侦听于 http://0.0.0.0:9990 2020-05-14 15:28:58,063 ERROR [org.jboss.as] (Controller Boot Thread) WFLYSRV0026: JBoss EAP 7.2.1.GA (WildFly Core 6.0.12.Final-redhat-00001) started (with errors) in 35479ms - Started 570 of 758 services (2 services failed or missing dependencies, 327 services are lazy, passive or on-demand) 2020-05-14 15:38:23,596 INFO [org.jboss.as.repository] (ServerService Thread Pool -- 94) WFLYDR0009: 内容 D:\jboss\jboss-eap-7.2\standalone\data ```

android app 安装在荣耀6x出现闪退,抓捕的错误如下

> debug运行后,在初始化的setContentView(R.layout.activity_mlogin);方法出现如下错误: # java.lang.RuntimeException: Unable to start activity ComponentInfo{com.medex.Activity.release/com.medex.Activity.miha.MLoginActivity}: java.lang.NullPointerException: Attempt to read from field 'android.os.MessageQueue android.os.Looper.mQueue' on a null object reference at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2793) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2864) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1567) at android.os.Handler.dispatchMessage(Handler.java:105) at android.os.Looper.loop(Looper.java:156) at android.app.ActivityThread.main(ActivityThread.java:6523) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:941) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:831) # Caused by: java.lang.NullPointerException: Attempt to read from field 'android.os.MessageQueue android.os.Looper.mQueue' on a null object reference at android.os.Handler.<init>(Handler.java:236) at android.view.accessibility.AccessibilityManager$MyHandler.<init>(AccessibilityManager.java:686) at android.view.accessibility.AccessibilityManager.<init>(AccessibilityManager.java:221) at android.view.accessibility.AccessibilityManager.getInstance(AccessibilityManager.java:205) at android.view.View.setFlags(View.java:11440) at android.view.ViewGroup.initViewGroup(ViewGroup.java:590) at android.view.ViewGroup.<init>(ViewGroup.java:579) at android.view.ViewGroup.<init>(ViewGroup.java:574) at android.view.ViewGroup.<init>(ViewGroup.java:570) at android.view.ViewGroup.<init>(ViewGroup.java:566) at android.widget.FrameLayout.<init>(FrameLayout.java:78) at com.android.internal.policy.DecorView.<init>(DecorView.java:247) at com.android.internal.policy.PhoneWindow.generateDecor(PhoneWindow.java:2401) at com.android.internal.policy.PhoneWindow.installDecor(PhoneWindow.java:2804) at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:443) at com.android.internal.policy.HwPhoneWindow.setContentView(HwPhoneWindow.java:280) at android.app.Activity.setContentView(Activity.java:2515) at com.medex.Activity.Base.a.onCreate(Unknown Source) at android.app.Activity.performCreate(Activity.java:6910) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2746) ... 9 more

使用连接池时无法初始化,也不报错不知到哪出了问题

package com.server; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.sql.Connection; import java.util.Properties; import org.apache.commons.dbcp.BasicDataSource; /** * 该类用于管理数据库连接 * @author adminitartor * */ public class DBUtil { //数据库连接池 private static BasicDataSource ds; static{ //初始化静态属性 //1加载配置文件 /* * java.util.Properties * 用来读取.properties文件,并解析其中 * 每一行内容,然后以key-value的形式保存 * 在当前实例中。 */ Properties prop = new Properties(); try { prop.load(new FileInputStream("config.properties")); String className = prop.getProperty("classname"); String url = prop.getProperty("url"); String username = prop.getProperty("username"); String password = prop.getProperty("password"); int maxActive = Integer.parseInt(prop.getProperty("maxactive")); int maxWait = Integer.parseInt(prop.getProperty("maxwait")); //初始化连接池 ds=new BasicDataSource(); //将JDBC建立连接所需要的信息设置到连接池中 //Class.forName(...) ds.setDriverClassName(className); //DriverManager.getConnection(...) ds.setUrl(url); ds.setUsername(username); ds.setPassword(password); //设置连接池最大连接数 ds.setMaxActive(maxActive); //设置最大等待时间 ds.setMaxWait(maxWait); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }catch(Exception e){ e.printStackTrace(); }finally { System.out.println(123); } //2根据配置文件初始化 } /** * 获取数据库连接 * @return */ public static Connection getConnection() throws Exception{ /* * 连接池提供的方法: * Connection getConnection() * 该方法可以返回一个连接池中可用连接。 * 这是一个阻塞方法,当连接池中有空闲连接 * 可以使用时会立刻返回,若当前连接池没有 * 可用连接时,会进入阻塞,阻塞时间由创建 * 连接池时通过setMaxWait设置的时间为准 * 在等待期间若有空闲连接着立即返回,当 * 超过最大等待时间仍没有可用连接时,该方 * 法会抛出超时异常。 */ return ds.getConnection(); } /** * 关闭给定的连接 * @param conn */ public static void closeConnection(Connection conn){ try { conn.setAutoCommit(true); /* * 若该连接是通过连接池获取的,那么调用 * 这个连接的close方法并不是与数据库断开 * 连接了,而仅仅是将该连接还给连接池。 */ conn.close(); } catch (Exception e) { e.printStackTrace(); } } }

自定义ViewGroup,调试抛出Error inflating class,求构造函数以外的原因?

照着https://blog.csdn.net/lmj623565791/article/details/43131133这个网址想实现一个圆形旋转菜单,调试时发现在主页面的setContentView一步抛出 Error inflating class......异常,即自己的自定义ViewGroup无法被初始化,度娘说是构造函数的原因,但我确实把所有能找到的不同参数情况都加上去了,经测也不是未引用完整包名的原因;请问诸位,还可能是什么原因? 先抛异常: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.asus.newsapplication/com.example.asus.newsapplication.MainPage}: android.view.InflateException: Binary XML file line #12: Error inflating class com.example.asus.newsapplication.CircleMenuLayout at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) at android.app.ActivityThread.access$800(ActivityThread.java:151) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5254) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700) Caused by: android.view.InflateException: Binary XML file line #12: Error inflating class com.example.asus.newsapplication.CircleMenuLayout at android.view.LayoutInflater.createView(LayoutInflater.java:633) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743) at android.view.LayoutInflater.rInflate(LayoutInflater.java:806) at android.view.LayoutInflater.inflate(LayoutInflater.java:504) at android.view.LayoutInflater.inflate(LayoutInflater.java:414) at android.view.LayoutInflater.inflate(LayoutInflater.java:365) at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) at com.example.asus.newsapplication.MainPage.onCreate(MainPage.java:16) at android.app.Activity.performCreate(Activity.java:5990) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)  at android.app.ActivityThread.access$800(ActivityThread.java:151)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:135)  at android.app.ActivityThread.main(ActivityThread.java:5254)  at java.lang.reflect.Method.invoke(Native Method)  at java.lang.reflect.Method.invoke(Method.java:372)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)  Caused by: java.lang.InstantiationException: Can't instantiate abstract class com.example.asus.newsapplication.CircleMenuLayout at java.lang.reflect.Constructor.newInstance(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:288) at android.view.LayoutInflater.createView(LayoutInflater.java:607) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)  at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)  at android.view.LayoutInflater.inflate(LayoutInflater.java:504)  at android.view.LayoutInflater.inflate(LayoutInflater.java:414)  at android.view.LayoutInflater.inflate(LayoutInflater.java:365)  at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)  at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)  at com.example.asus.newsapplication.MainPage.onCreate(MainPage.java:16)  at android.app.Activity.performCreate(Activity.java:5990)  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)  at android.app.ActivityThread.access$800(ActivityThread.java:151)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:135)  at android.app.ActivityThread.main(ActivityThread.java:5254)  at java.lang.reflect.Method.invoke(Native Method)  at java.lang.reflect.Method.invoke(Method.java:372)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)  再贴图片: ![图片说明](https://img-ask.csdn.net/upload/201806/05/1528204867_673557.png) ![图片说明](https://img-ask.csdn.net/upload/201806/05/1528204937_810371.png) ![图片说明](https://img-ask.csdn.net/upload/201806/05/1528204988_880336.png)

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

程序员请照顾好自己,周末病魔差点一套带走我。

程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

点沙成金:英特尔芯片制造全过程揭密

“亚马逊丛林里的蝴蝶扇动几下翅膀就可能引起两周后美国德州的一次飓风……” 这句人人皆知的话最初用来描述非线性系统中微小参数的变化所引起的系统极大变化。 而在更长的时间尺度内,我们所生活的这个世界就是这样一个异常复杂的非线性系统…… 水泥、穹顶、透视——关于时间与技艺的蝴蝶效应 公元前3000年,古埃及人将尼罗河中挖出的泥浆与纳特龙盐湖中的矿物盐混合,再掺入煅烧石灰石制成的石灰,由此得来了人...

上班一个月,后悔当初着急入职的选择了

最近有个老铁,告诉我说,上班一个月,后悔当初着急入职现在公司了。他之前在美图做手机研发,今年美图那边今年也有一波组织优化调整,他是其中一个,在协商离职后,当时捉急找工作上班,因为有房贷供着,不能没有收入来源。所以匆忙选了一家公司,实际上是一个大型外包公司,主要派遣给其他手机厂商做外包项目。**当时承诺待遇还不错,所以就立马入职去上班了。但是后面入职后,发现薪酬待遇这块并不是HR所说那样,那个HR自...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

外包程序员的幸福生活

今天给你们讲述一个外包程序员的幸福生活。男主是Z哥,不是在外包公司上班的那种,是一名自由职业者,接外包项目自己干。接下来讲的都是真人真事。 先给大家介绍一下男主,Z哥,老程序员,是我十多年前的老同事,技术大牛,当过CTO,也创过业。因为我俩都爱好喝酒、踢球,再加上住的距离不算远,所以一直也断断续续的联系着,我对Z哥的状况也有大概了解。 Z哥几年前创业失败,后来他开始干起了外包,利用自己的技术能...

C++11:一些微小的变化(新的数据类型、template表达式内的空格、nullptr、std::nullptr_t)

本文介绍一些C++的两个新特性,它们虽然微小,但对你的编程十分重要 一、Template表达式内的空格 C++11标准之前建议在“在两个template表达式的闭符之间放一个空格”的要求已经过时了 例如: vector&lt;list&lt;int&gt; &gt;; //C++11之前 vector&lt;list&lt;int&gt;&gt;; //C++11 二、nullptr ...

优雅的替换if-else语句

场景 日常开发,if-else语句写的不少吧??当逻辑分支非常多的时候,if-else套了一层又一层,虽然业务功能倒是实现了,但是看起来是真的很不优雅,尤其是对于我这种有强迫症的程序"猿",看到这么多if-else,脑袋瓜子就嗡嗡的,总想着解锁新姿势:干掉过多的if-else!!!本文将介绍三板斧手段: 优先判断条件,条件不满足的,逻辑及时中断返回; 采用策略模式+工厂模式; 结合注解,锦...

深入剖析Springboot启动原理的底层源码,再也不怕面试官问了!

大家现在应该都对Springboot很熟悉,但是你对他的启动原理了解吗?

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

为什么你不想学习?只想玩?人是如何一步一步废掉的

不知道是不是只有我这样子,还是你们也有过类似的经历。 上学的时候总有很多光辉历史,学年名列前茅,或者单科目大佬,但是虽然慢慢地长大了,你开始懈怠了,开始废掉了。。。 什么?你说不知道具体的情况是怎么样的? 我来告诉你: 你常常潜意识里或者心理觉得,自己真正的生活或者奋斗还没有开始。总是幻想着自己还拥有大把时间,还有无限的可能,自己还能逆风翻盘,只不是自己还没开始罢了,自己以后肯定会变得特别厉害...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试:第十六章:Java中级开发(16k)

HashMap底层实现原理,红黑树,B+树,B树的结构原理 Spring的AOP和IOC是什么?它们常见的使用场景有哪些?Spring事务,事务的属性,传播行为,数据库隔离级别 Spring和SpringMVC,MyBatis以及SpringBoot的注解分别有哪些?SpringMVC的工作原理,SpringBoot框架的优点,MyBatis框架的优点 SpringCould组件有哪些,他们...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

【阿里P6面经】二本,curd两年,疯狂复习,拿下阿里offer

二本的读者,在老东家不断学习,最后逆袭

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

《经典算法案例》01-08:如何使用质数设计扫雷(Minesweeper)游戏

我们都玩过Windows操作系统中的经典游戏扫雷(Minesweeper),如果把质数当作一颗雷,那么,表格中红色的数字哪些是雷(质数)?您能找出多少个呢?文中用列表的方式罗列了10000以内的自然数、质数(素数),6的倍数等,方便大家观察质数的分布规律及特性,以便对算法求解有指导意义。另外,判断质数是初学算法,理解算法重要性的一个非常好的案例。

《Oracle Java SE编程自学与面试指南》最佳学习路线图(2020最新版)

正确选择比瞎努力更重要!

面试官:你连SSO都不懂,就别来面试了

大厂竟然要考我SSO,卧槽。

微软为一人收购一公司?破解索尼程序、写黑客小说,看他彪悍的程序人生!...

作者 | 伍杏玲出品 | CSDN(ID:CSDNnews)格子衬衫、常掉发、双肩包、修电脑、加班多……这些似乎成了大众给程序员的固定标签。近几年流行的“跨界风”开始刷新人们对程序员的...

终于,月薪过5万了!

来看几个问题想不想月薪超过5万?想不想进入公司架构组?想不想成为项目组的负责人?想不想成为spring的高手,超越99%的对手?那么本文内容是你必须要掌握的。本文主要详解bean的生命...

我说我懂多线程,面试官立马给我发了offer

不小心拿了几个offer,有点烦

自从喜欢上了B站这12个UP主,我越来越觉得自己是个废柴了!

不怕告诉你,我自从喜欢上了这12个UP主,哔哩哔哩成为了我手机上最耗电的软件,几乎每天都会看,可是吧,看的越多,我就越觉得自己是个废柴,唉,老天不公啊,不信你看看…… 间接性踌躇满志,持续性混吃等死,都是因为你们……但是,自己的学习力在慢慢变强,这是不容忽视的,推荐给你们! 都说B站是个宝,可是有人不会挖啊,没事,今天咱挖好的送你一箩筐,首先啊,我在B站上最喜欢看这个家伙的视频了,为啥 ,咱撇...

立即提问
相关内容推荐