废话不多说,上代码 public class ArrayListTest { @Test public void testList() { List<Long> longList = new ArrayList<>(); longList.add(1L); longList.add(2L); longList.add(3L); longList.add(4L); longList.forEach(System.out::println); System.out.println(&q…
问题: 使用工具类Arrays.asList()方法把数组转换成集合时,不能使用修改集合相关的方法,比如add,remove.这个ArrayList是Arrays类自己定义的一个内部类!这个内部类没有实现add().remove()方法,而是直接使用它的父类 的相应方法.而父类中的add()和remove()是直接抛出异常的! 源码: 解决方法: 总结: 1.Arrays.asList()底层其实还是数组; 2.如果使用了Arrays.asList()的话,最好不要使用其集合的操作方法; 3.…
报错: java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: Root WebApplicationContext: startup date [Thu Nov 27 08:53:38 CST 2014]; root of context hierarchy 解决: 先关闭tomc…
开着idea,死机了,关机重启.重启之后,重新打开idea报错java.lang.AssertionError:upexpected content storage modification. goole得到: If you cannot even open your project in IntelliJ: Close IntelliJ Go to the directory <your_home>/.IntelliJIdeaXX/system/cache where XX is your…
主要原因是maven项目里面的jar包吗,没有导入到项目中 maven web 项目中启动报错 Java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet 错误描述: Java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet 问题解析: Maven项目中所有依赖(jdk/jar/c…
最近用yarn cluster方式提交spark任务时,有时会报错,报错几率是40%,报错如下: 18/03/15 21:50:36 116 ERROR ApplicationMaster91: User class threw exception: org.apache.spark.sql.AnalysisException: java.lang.NoSuchFieldError: HIVE_MOVE_FILES_THREAD_COUNT; org.apache.spark.sql.Analy…
在做文件上传时,当写入上传的文件到文件时,会报错“java.lang.IllegalStateException: File has been moved - cannot be read again”,网上一般说需要配置maxInMemorySize,自己测试发现,maxInMemorySize确实会影响结果,并且项目还跟写入文件到文件夹的transferTo(File dest)方法也有关系,以下是报错截图: 问题说明 通过debug和浏览器提示,浏览器端代码没有问题,问题跟服务端专门处理上…
现象:项目报错java.lang.ClassNotFoundException: org.common.SessionListener,并且myeclipse左侧Package Explorer中项目目录的WEB-INF下显示多了个classes文件夹.既然报错是ClassNotFoundException,就去tomcat的WEB-INF/classes下找该项目,的确没有class文件. 解决方法:右击项目,点击properties(或者右击项目,选择build path--config b…
问题描述 最近在写一些单元测试用例,为了避免连接外界服务,所有选择mock了数据库Dao层,计划将数据库所需要的数据存在List中,在类加载的时候初始化List并且填充数据.代码如下: public class UserDaoMock extends UserDao { @Override public List<UserInfo> selectUserInfo() { return getUserInfo(); } static { initUserInfo(); } public stat…
Spring boot Unable to start embedded Tomcat 报错 java.lang.NoSuchMethodError: javax.servlet.ServletContext.getVirtualServerName() 解决方法: 将Tomcat 安装目录下 的 servlet-api.jar 复制进 Jdk安装目录下的 /jre/lib/ext 下 问题解决…