java:Pixel类(Point的子类),表示屏幕上的像素

初学真是难guo
设计一个Pixel类(Point的子类),表示屏幕上的像素,为该类提供一个作为程序执行入口的main方法,测试整个application的正确性。

代码生成.class后,总是显示错误为
Exception in thread "main" java.lang.NullPointerException
at Pixel.main(Point.java:37)

class Point{
int width;
int length;
public void setpoint(int x,int y){
width=x;
length=y;}
public void clear(){
width=0;
length=0;}}

class Color{
int red,green,blue;
void bianse(){}
void bianse(int red,int green,int blue){
this.red=red;
this.green=green;
this.blue=blue;}
public void StringtoString(){
System.out.println("red="+red+"green="+green+";blue="+blue);
}}

class Pixel extends Point{
Color color;
public void clear(){
super.clear();//继承并延展
color=null;}
static public void main(String args[]){ //main
Pixel p1=new Pixel();
p1.clear();
p1.color.bianse(255,0,0);
p1.setpoint(3,3);
System.out.println(p1.width+"*"+p1.length);

p1.color.StringtoString(); }}

2个回答

java的变量都是初始化为null的,不像c一样会初始化一个对象,所以java定义对象都要写new。你的程序在声明Pixel的私有变量时就可以写new。

class Pixel extends Point{
    Color color = new Color();

其次你的 color = null 语句很危险,因为后续没有对应的赋值语句,尽管你现在的代码用不到,但最好加上。

JonathanYan
JonathanYan 回复_reid: 最好写一个setColor的函数,把color设置到默认值。
8 个月之前 回复
JonathanYan
JonathanYan 回复_reid: 那就没啥问题,我说危险不是赋值null,而是你后面没有重新给他赋值新的变量
8 个月之前 回复
qq_43739564
_reid 谢谢~null是抄的书
8 个月之前 回复

class Pixel extends Point{
Color color;
public void clear(){
super.clear();//继承并延展
color=null;}
这里的 color 没有初始化,也没有构造函数,也没有被设置

p1.color.bianse(255,0,0);
这显然就是null错误了。

改法有很多,比如
public void clear(){
super.clear();//继承并延展
color=null;}
修改为
public void clear(){
super.clear();//继承并延展
color=new Color();}

caozhy
贵阳老马马善福专业维修游泳池堵漏防水工程 回复_reid: 问题解决请点下我回答下面的采纳
8 个月之前 回复
qq_43739564
_reid 谢谢!=null抄得书 我去看看
8 个月之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
java内存溢出问题,不确定哪里出的问题

项目运行的时候出现了内存溢出情况,复现方式无法确定,大概出现了五六次,每次复现的方式都不一样,下面是我用MAT工具分析的dump文件 ![图片说明](https://img-ask.csdn.net/upload/202001/20/1579508231_612899.png) ![图片说明](https://img-ask.csdn.net/upload/202001/20/1579508244_502327.png) 除了hibernate里的那两个对象,其他的1000多万个对象里全是integer类型的对象 这是当时出现的时候产生的异常 ``` 2020-01-17 13:32:55 ERROR [DruidDataSource.java:2469] - create connection SQLException, url: jdbc:mysql://localhost:55060/mcs?useUnicode=true&characterEncoding=utf-8, errorCode 0, state 08S01 com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet successfully received from the server was 1 milliseconds ago. The last packet sent successfully to the server was 0 milliseconds ago. at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:526) at com.mysql.jdbc.Util.handleNewInstance(Util.java:425) at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:990) at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3517) at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3417) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3860) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:864) at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1707) at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1217) at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2189) at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2220) at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2015) at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:768) at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47) at sun.reflect.GeneratedConstructorAccessor118.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:526) at com.mysql.jdbc.Util.handleNewInstance(Util.java:425) at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:385) at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:323) at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1513) at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1578) at com.alibaba.druid.pool.DruidDataSource$CreateConnectionThread.run(DruidDataSource.java:2466) Caused by: java.io.EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost. at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2969) at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3427) ... 19 more 2020-01-17 13:33:03 ERROR [DiskStorageFactory.java:495] - Disk Write of mcs_preset_rlat failed: java.lang.OutOfMemoryError: GC overhead limit exceeded at net.sf.ehcache.util.MemoryEfficientByteArrayOutputStream.getBytes(MemoryEfficientByteArrayOutputStream.java:65) at net.sf.ehcache.util.MemoryEfficientByteArrayOutputStream.serialize(MemoryEfficientByteArrayOutputStream.java:99) at net.sf.ehcache.store.disk.DiskStorageFactory.serializeElement(DiskStorageFactory.java:405) at net.sf.ehcache.store.disk.DiskStorageFactory.write(DiskStorageFactory.java:384) at net.sf.ehcache.store.disk.DiskStorageFactory$DiskWriteTask.call(DiskStorageFactory.java:485) at net.sf.ehcache.store.disk.DiskStorageFactory$PersistentDiskWriteTask.call(DiskStorageFactory.java:1088) at net.sf.ehcache.store.disk.DiskStorageFactory$PersistentDiskWriteTask.call(DiskStorageFactory.java:1072) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292) 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:745) 2020-01-17 13:32:59 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-17 13:32:59 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-17 13:32:55 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-17 13:33:16 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-17 13:33:27 WARN [SqlExceptionHelper.java:143] - SQL Error: 0, SQLState: null 2020-01-17 13:33:27 ERROR [SqlExceptionHelper.java:144] - wait millis 7401, active 16, maxActive 40, creating 1 2020-01-17 13:33:27 INFO [GetCWRCapHandler.java:114] - 解析录像服务器上报心跳协议过程中出现异常:org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Could not open connection 2020-01-17 13:33:33 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-17 13:33:33 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-17 13:33:49 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-17 13:33:49 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-17 13:33:49 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-17 13:33:49 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-17 13:33:49 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-17 13:33:53 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-17 13:33:53 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-17 13:33:53 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-17 13:34:02 WARN [SqlExceptionHelper.java:143] - SQL Error: 0, SQLState: null 2020-01-17 13:34:02 ERROR [SqlExceptionHelper.java:144] - wait millis 5503, active 18, maxActive 40, creating 1 2020-01-17 13:34:02 INFO [GetCWRCapHandler.java:114] - 解析录像服务器上报心跳协议过程中出现异常:org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Could not open connection 2020-01-17 13:34:04 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-17 13:34:08 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-17 13:34:12 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-17 13:34:12 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-17 13:34:14 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-17 13:34:14 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-17 13:34:14 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-17 13:34:17 WARN [SqlExceptionHelper.java:143] - SQL Error: 0, SQLState: null 2020-01-17 13:34:17 ERROR [SqlExceptionHelper.java:144] - wait millis 5485, active 19, maxActive 40, creating 1 2020-01-17 13:34:17 INFO [GetCWRCapHandler.java:114] - 解析录像服务器上报心跳协议过程中出现异常:org.springframework.orm.hibernate3.HibernateJdbcException: JDBC exception on Hibernate data access: SQLException for SQL [n/a]; SQL state [null]; error code [0]; Could not open connection; nested exception is org.hibernate.exception.GenericJDBCException: Could not open connection 2020-01-17 13:34:17 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-17 13:34:27 INFO [DeviceCache.java:249] - 设备状态及报警维护过程中出现异常 2020-01-17 13:34:35 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-17 13:34:35 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-17 13:34:42 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-17 13:34:42 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-17 13:34:44 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-17 13:34:44 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-17 13:34:52 WARN [SqlExceptionHelper.java:143] - SQL Error: 0, SQLState: null 2020-01-17 13:34:52 ERROR [SqlExceptionHelper.java:144] - wait millis 7301, active 22, maxActive 40, creating 1 2020-01-17 13:34:52 INFO [GetCWRCapHandler.java:114] - 解析录像服务器上报心跳协议过程中出现异常:org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Could not open connection 2020-01-17 13:34:53 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-17 13:35:05 ERROR [DiskStorageFactory.java:495] - Disk Write of mcs_roll_preset failed: java.lang.OutOfMemoryError: GC overhead limit exceeded 2020-01-17 13:35:18 WARN [SqlExceptionHelper.java:143] - SQL Error: 0, SQLState: null 2020-01-17 13:35:18 ERROR [SqlExceptionHelper.java:144] - Error 2020-01-17 13:35:50 WARN [SqlExceptionHelper.java:143] - SQL Error: 0, SQLState: null 2020-01-17 13:35:50 ERROR [SqlExceptionHelper.java:144] - Error 2020-01-17 13:36:13 WARN [SqlExceptionHelper.java:143] - SQL Error: 1205, SQLState: 40001 2020-01-17 13:36:13 ERROR [SqlExceptionHelper.java:144] - Lock wait timeout exceeded; try restarting transaction 2020-01-17 13:36:13 WARN [SqlExceptionHelper.java:143] - SQL Error: 1205, SQLState: 40001 2020-01-17 13:36:24 ERROR [SqlExceptionHelper.java:144] - Lock wait timeout exceeded; try restarting transaction 2020-01-17 13:36:13 WARN [SqlExceptionHelper.java:143] - SQL Error: 1205, SQLState: 40001 2020-01-17 13:37:01 ERROR [SqlExceptionHelper.java:144] - Lock wait timeout exceeded; try restarting transaction 2020-01-17 13:37:43 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-17 13:36:37 WARN [SqlExceptionHelper.java:143] - SQL Error: 1205, SQLState: 40001 2020-01-17 13:36:33 WARN [SqlExceptionHelper.java:143] - SQL Error: 1205, SQLState: 40001 2020-01-17 13:36:22 WARN [SqlExceptionHelper.java:143] - SQL Error: 1205, SQLState: 40001 ``` 现在就是无法确定到底哪里导致的内存溢出? 这个是上次出现的异常和代码 ``` 2020-01-13 13:21:44 WARN [SqlExceptionHelper.java:143] - SQL Error: 1205, SQLState: 40001 2020-01-13 13:21:44 ERROR [SqlExceptionHelper.java:144] - Lock wait timeout exceeded; try restarting transaction 2020-01-13 13:23:55 INFO [MQTTProtocolHandler.java:283] - 接收到设备接入协议:{"topic":"info/deviceBaseInfo/BHIP118-S/00:00:01:A6:00:A2","reportTime":"256573751","decodeCapacity":{"totalLevel":2,"totalBlock":36,"totalPixel":16588800},"outputList":[{"status":"start","ratio":"UHD","pixel":"3840*2160","type":"UDP","url":"udp://231.0.100.80:7001"},{"status":"start","ratio":"HD","pixel":"960*540","type":"UDP","url":"udp://231.0.101.80:7001"},{"status":"start","ratio":"SD","pixel":"352*288","type":"UDP","url":"udp://231.0.102.80:7001"},{"status":"stop","ratio":"UHD","pixel":"3840*2160","type":"RTMP","url":"rtmp://192.168.15.80:1935/live/100"},{"status":"stop","ratio":"HD","pixel":"960*540","type":"RTMP","url":"rtmp://192.168.15.124:1935/live/101"},{"status":"stop","ratio":"SD","pixel":"352*288","type":"RTMP","url":"rtmp://192.168.15.80:1935/live/102"}],"baseInfo":{"deviceType":"BHIP118-S","code":"00:00:01:A6:00:A2","version":"v1.0.0.11","ip":"192.168.16.80"},"online":true} 2020-01-13 13:23:59 INFO [DeviceCache.java:127] - 接收到新增/更新设备信息:00:00:01:A6:00:A2 :BaseInfo [type=0,name=BHIP118-S,ip=192.168.16.80,port=0,code=00:00:01:A6:00:A2,groupCode=null,groupIndex=0,online=true,multiCastTime=0,ver=v1.0.0.11,channel=0,reserve=0,lockStatus=null,workMode=null,videoPixerls=null,kvmMode=null,serialNumber=null,sdipPortInfo is null,hdIpPortInfo is null,audioIpPortInfo is null,outputList[SourceOutput [ratio=UHD, url=udp://231.0.100.80:7001, pixel=3840*2160, channel=0, SourceOutput [ratio=HD, url=udp://231.0.101.80:7001, pixel=960*540, channel=0, SourceOutput [ratio=SD, url=udp://231.0.102.80:7001, pixel=352*288, channel=0, SourceOutput [ratio=UHD, url=rtmp://192.168.15.80:1935/live/100, pixel=3840*2160, channel=0, SourceOutput [ratio=HD, url=rtmp://192.168.15.124:1935/live/101, pixel=960*540, channel=0, SourceOutput [ratio=SD, url=rtmp://192.168.15.80:1935/live/102, pixel=352*288, channel=0],callStatus=null] 2020-01-13 13:24:06 INFO [MultiCastDeviceInfoHandler.java:229] - 更新视频合成器设备信息: Device [id=ff8080816f694555016f6a4bf61e158c, code=00:00:01:A6:00:A2, name=192.168.16.80, ip=192.168.16.80, port=0, status=0, type=BHIP118, deviceType=BHIP118-S, stamp=2020-01-03 15:26:00, abilityInfo=null, netCardInfo=null] 2020-01-13 13:24:53 INFO [MultiCastDeviceInfoHandler.java:364] - 更新解码器信息:Decoder [IP=192.168.16.80, Port=0, Channel=0, totalBlocks=36, totalLevel=2, uRefWidth=1920, uRefHeight=1080, audioPort=0, totalPixel=16588800, deviceTypeName=BHIP118-S, pixelsWidth=null, pixelsHeight=null] 2020-01-13 13:25:17 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-13 13:25:17 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-13 13:25:17 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-13 13:25:19 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-13 13:25:28 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-13 13:25:42 WARN [SqlExceptionHelper.java:143] - SQL Error: 0, SQLState: null 2020-01-13 13:25:42 ERROR [SqlExceptionHelper.java:144] - wait millis 14463, active 11, maxActive 40, creating 1 2020-01-13 13:25:46 ERROR [DiskStorageFactory.java:495] - Disk Write of mcs_playback_task failed: java.lang.OutOfMemoryError: GC overhead limit exceeded 2020-01-13 13:25:48 WARN [SqlExceptionHelper.java:143] - SQL Error: 0, SQLState: null 2020-01-13 13:25:50 ERROR [SqlExceptionHelper.java:144] - wait millis 18056, active 11, maxActive 40, creating 1 2020-01-13 13:25:50 ERROR [DiskStorageFactory.java:495] - Disk Write of mcs_source_volume failed: java.lang.OutOfMemoryError: GC overhead limit exceeded 2020-01-13 13:25:51 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-13 13:25:51 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-13 13:25:51 INFO [GetCWRCapHandler.java:114] - 解析录像服务器上报心跳协议过程中出现异常:org.springframework.orm.hibernate3.HibernateJdbcException: JDBC exception on Hibernate data access: SQLException for SQL [n/a]; SQL state [null]; error code [0]; Could not open connection; nested exception is org.hibernate.exception.GenericJDBCException: Could not open connection 2020-01-13 13:25:51 INFO [GetCWRCapHandler.java:114] - 解析录像服务器上报心跳协议过程中出现异常:org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Could not open connection 2020-01-13 13:25:58 ERROR [DiskStorageFactory.java:495] - Disk Write of mcs_kvm failed: java.lang.OutOfMemoryError: GC overhead limit exceeded 2020-01-13 13:25:56 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-13 13:25:56 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-13 13:26:03 ERROR [DiskStorageFactory.java:495] - Disk Write of mcs_video_terminal failed: java.lang.OutOfMemoryError: GC overhead limit exceeded 2020-01-13 13:26:05 ERROR [DiskStorageFactory.java:495] - Disk Write of mcs_pic_layer failed: java.lang.OutOfMemoryError: GC overhead limit exceeded 2020-01-13 13:26:05 ERROR [DiskStorageFactory.java:495] - Disk Write of mcs_template failed: java.lang.OutOfMemoryError: GC overhead limit exceeded 2020-01-13 13:26:05 ERROR [DiskStorageFactory.java:495] - Disk Write of mcs_multicast_address failed: java.lang.OutOfMemoryError: GC overhead limit exceeded 2020-01-13 13:26:08 ERROR [DiskStorageFactory.java:495] - Disk Write of mcs_mass_source failed: java.lang.OutOfMemoryError: GC overhead limit exceeded 2020-01-13 13:26:08 ERROR [DiskStorageFactory.java:495] - Disk Write of mcs_pic_encoder_block failed: java.lang.OutOfMemoryError: GC overhead limit exceeded 2020-01-13 13:26:08 ERROR [DiskStorageFactory.java:495] - Disk Write of mcs_ipc_preset_group failed: java.lang.OutOfMemoryError: GC overhead limit exceeded 2020-01-13 13:26:08 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-13 13:26:13 ERROR [DiskStorageFactory.java:495] - Disk Write of mcs_video_terminal failed: java.lang.OutOfMemoryError: GC overhead limit exceeded 2020-01-13 13:26:17 ERROR [DiskStorageFactory.java:495] - Disk Write of mcs_record_layer_block failed: java.lang.OutOfMemoryError: GC overhead limit exceeded 2020-01-13 13:26:24 ERROR [DiskStorageFactory.java:495] - Disk Write of mcs_video_meeting failed: java.lang.OutOfMemoryError: GC overhead limit exceeded 2020-01-13 13:26:28 ERROR [DiskStorageFactory.java:495] - Disk Write of mcs_audio_preset_rlat failed: java.lang.OutOfMemoryError: GC overhead limit exceeded 2020-01-13 13:26:28 ERROR [DiskStorageFactory.java:495] - Disk Write of mcs_preset failed: java.lang.OutOfMemoryError: GC overhead limit exceeded 2020-01-13 13:26:28 ERROR [DiskStorageFactory.java:495] - Disk Write of mcs_layer_block failed: java.lang.OutOfMemoryError: GC overhead limit exceeded 2020-01-13 13:26:28 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-13 13:26:32 WARN [SqlExceptionHelper.java:143] - SQL Error: 0, SQLState: null 2020-01-13 13:26:32 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-13 13:26:32 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-13 13:26:32 ERROR [DiskStorageFactory.java:495] - Disk Write of mcs_encoder failed: java.lang.OutOfMemoryError: GC overhead limit exceeded 2020-01-13 13:26:52 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-13 13:27:07 ERROR [SqlExceptionHelper.java:144] - wait millis 20150, active 12, maxActive 40, creating 1 2020-01-13 13:26:50 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-13 13:26:46 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-13 13:26:46 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-13 13:26:41 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-13 13:26:41 ERROR [SqlExceptionHelper.java:144] - wait millis 23244, active 12, maxActive 40, creating 1 2020-01-13 13:26:41 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-13 13:26:41 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-13 13:30:29 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-13 13:30:25 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-13 13:30:07 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-13 13:30:07 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 2020-01-13 13:30:07 WARN [DruidDataSource.java:1258] - get connection timeout retry : 1 ``` 这个是组播上报的设备信息,因为组播是一秒钟上报了好几次,是不是这里一直占用着连接 ``` public void run() { try { ms = new MulticastSocket(multiCastPort);//建立组播套接字 ms.setReceiveBufferSize(65535); // ms.setNetworkInterface(NetworkInterface.getByInetAddress(localAddress)); ms.joinGroup(InetAddress.getByName(multiCastIP));//加入组播组 LogHome.getLog().info("正常启动监听" + localAddress.getHostAddress()); byte[] buffer = null; DatagramPacket dp = null; while (true) { try { if (IsStop) { break; } buffer = new byte[1400]; dp = new DatagramPacket(buffer, buffer.length); LogHome.getLog().debug("等待接受组播信息:"); ms.receive(dp); MultiCastInfoParser info = new MultiCastInfoParser(dp.getData()); DeviceCache.baseInfoOf1004Handler(info.parse()); } catch (Exception e) { if (IsStop) {// 如果换网卡可能会出问题 break; } else { if (ms.isClosed()) { ms = new MulticastSocket(multiCastPort); ms.setNetworkInterface(NetworkInterface.getByInetAddress(localAddress)); ms.joinGroup(InetAddress.getByName(multiCastIP)); } } LogHome.getLog().error("接受并设置组播信息失败",e); }finally{ Thread.sleep(1); } } } catch (Exception e) { e.printStackTrace(); try { if (listenerList.containsKey(localAddress.getHostAddress())) { listenerList.remove(localAddress.getHostAddress()); } } catch (Exception ex) { LogHome.getLog().error(ex); } } ```

java.lang.ClassNotFoundException: com.android.id.impl.IdProviderImpl

巨量引擎SDK接入报错java.lang.ClassNotFoundException: com.android.id.impl.IdProviderImpl 求救,非常感谢! ``` 05/15 16:49:59: Launching 'app' on Pixel 2 API 28. $ adb shell am start -n "com.cn.leaf.demo/com.cn.leaf.demo.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER Connected to process 6411 on device 'Pixel_2_API_28 [emulator-5554]'. Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page. I/MultiDex: VM with version 2.1.0 has multidex support Installing application VM has multidex support, MultiDex support library is disabled. W/om.cn.leaf.dem: Accessing hidden method Landroid/graphics/drawable/Drawable;->getOpticalInsets()Landroid/graphics/Insets; (light greylist, linking) Accessing hidden field Landroid/graphics/Insets;->left:I (light greylist, linking) Accessing hidden field Landroid/graphics/Insets;->right:I (light greylist, linking) Accessing hidden field Landroid/graphics/Insets;->top:I (light greylist, linking) Accessing hidden field Landroid/graphics/Insets;->bottom:I (light greylist, linking) W/om.cn.leaf.dem: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (light greylist, reflection) W/om.cn.leaf.dem: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (light greylist, reflection) W/om.cn.leaf.dem: Accessing hidden method Landroid/widget/TextView;->getTextDirectionHeuristic()Landroid/text/TextDirectionHeuristic; (light greylist, linking) D/TrackerDr: f#init: D/TrackerDr: i#init: E/i#IdentifierManager: reflect exception! java.lang.ClassNotFoundException: com.android.id.impl.IdProviderImpl at java.lang.Class.classForName(Native Method) at java.lang.Class.forName(Class.java:453) at java.lang.Class.forName(Class.java:378) at com.bytedance.a.i$a.<clinit>(SourceFile:195) at com.bytedance.a.i$a.a(SourceFile:185) at com.bytedance.a.i.a(SourceFile:106) at com.bytedance.a.i.<init>(SourceFile:49) at com.bytedance.a.i.b(SourceFile:41) at com.bytedance.a.i.a(SourceFile:34) at com.bytedance.a.g.a(SourceFile:46) at com.bytedance.a.b.a(SourceFile:33) at com.bytedance.applog.b.i.<init>(SourceFile:67) at com.bytedance.applog.AppLog.init(SourceFile:106) at com.cn.leaf.demo.MainActivity.initConfig(MainActivity.java:133) at com.cn.leaf.demo.MainActivity.PerMissions(MainActivity.java:186) at com.cn.leaf.demo.MainActivity.judgeBrand(MainActivity.java:265) at com.cn.leaf.demo.MainActivity.onCreate(MainActivity.java:56) at android.app.Activity.performCreate(Activity.java:7136) at android.app.Activity.performCreate(Activity.java:7127) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6669) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) Caused by: java.lang.ClassNotFoundException: Didn't find class "com.android.id.impl.IdProviderImpl" on path: DexPathList[[zip file "/data/app/com.cn.leaf.demo-XfKMKxO94jFGo_lzV_gX6A==/base.apk"],nativeLibraryDirectories=[/data/app/com.cn.leaf.demo-XfKMKxO94jFGo_lzV_gX6A==/lib/x86, /data/app/com.cn.leaf.demo-XfKMKxO94jFGo_lzV_gX6A==/base.apk!/lib/x86, /system/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134) at java.lang.ClassLoader.loadClass(ClassLoader.java:379) at java.lang.ClassLoader.loadClass(ClassLoader.java:312) at java.lang.Class.classForName(Native Method)  at java.lang.Class.forName(Class.java:453)  at java.lang.Class.forName(Class.java:378)  at com.bytedance.a.i$a.<clinit>(SourceFile:195)  at com.bytedance.a.i$a.a(SourceFile:185)  at com.bytedance.a.i.a(SourceFile:106)  at com.bytedance.a.i.<init>(SourceFile:49)  at com.bytedance.a.i.b(SourceFile:41)  at com.bytedance.a.i.a(SourceFile:34)  at com.bytedance.a.g.a(SourceFile:46)  at com.bytedance.a.b.a(SourceFile:33)  at com.bytedance.applog.b.i.<init>(SourceFile:67)  at com.bytedance.applog.AppLog.init(SourceFile:106)  at com.cn.leaf.demo.MainActivity.initConfig(MainActivity.java:133)  at com.cn.leaf.demo.MainActivity.PerMissions(MainActivity.java:186)  at com.cn.leaf.demo.MainActivity.judgeBrand(MainActivity.java:265)  at com.cn.leaf.demo.MainActivity.onCreate(MainActivity.java:56)  at android.app.Activity.performCreate(Activity.java:7136)  at android.app.Activity.performCreate(Activity.java:7127)  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)  at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)  at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)  at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)  at android.os.Handler.dispatchMessage(Handler.java:106)  at android.os.Looper.loop(Looper.java:193)  at android.app.ActivityThread.main(ActivityThread.java:6669)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)  ```

Could not execute method for android :onClicked

最近在学android的camera,在拍照按钮的点击事件中做了如下参数设置: ``` public void capture(View view){ if(mCamera!=null){ WindowManager manager= (WindowManager) getSystemService(Context.WINDOW_SERVICE); Display display=manager.getDefaultDisplay(); Log.i("capture",display.getWidth()+" "+display.getHeight()); Camera.Parameters parameters=mCamera.getParameters(); //设置拍照格式 parameters.setPictureFormat(PixelFormat.YCbCr_422_SP); //设置拍照大小 parameters.setPictureSize(213,350); //设置自动对焦 parameters.setFlashMode(Camera.Parameters.FOCUS_MODE_AUTO); mCamera.setParameters(parameters); mCamera.autoFocus(new Camera.AutoFocusCallback() { @Override public void onAutoFocus(boolean success, Camera camera) { mCamera.takePicture(null,null,mPictureCallback); } }); } } ``` 点击拍照按钮的时候程序崩溃了,出现如下的日志信息: ``` Process: com.example.vampire.facelearning, PID: 14489 java.lang.IllegalStateException: Could not execute method for android:onClick at android.view.View$DeclaredOnClickListener.onClick(View.java:4461) at android.view.View.performClick(View.java:5207) at android.view.View$PerformClick.run(View.java:21177) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5432) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:735) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625) Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Method.invoke(Native Method) at android.view.View$DeclaredOnClickListener.onClick(View.java:4456) at android.view.View.performClick(View.java:5207)  at android.view.View$PerformClick.run(View.java:21177)  at android.os.Handler.handleCallback(Handler.java:739)  at android.os.Handler.dispatchMessage(Handler.java:95)  at android.os.Looper.loop(Looper.java:148)  at android.app.ActivityThread.main(ActivityThread.java:5432)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:735)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)  Caused by: java.lang.RuntimeException: setParameters failed at android.hardware.Camera.native_setParameters(Native Method) at android.hardware.Camera.setParameters(Camera.java:2003) at com.example.vampire.facelearning.CustomCamera.capture(CustomCamera.java:85) at java.lang.reflect.Method.invoke(Native Method)  at android.view.View$DeclaredOnClickListener.onClick(View.java:4456)  at android.view.View.performClick(View.java:5207)  at android.view.View$PerformClick.run(View.java:21177)  at android.os.Handler.handleCallback(Handler.java:739)  at android.os.Handler.dispatchMessage(Handler.java:95)  at android.os.Looper.loop(Looper.java:148)  at android.app.ActivityThread.main(ActivityThread.java:5432)  at java.lang.reflect.Method.invoke(Native Method)  ``` 我把mCamera.setParameters(parameters);注析掉后程序就可以进行拍照了,但遇到了另一个问题。拍照获取的图片尺寸非常小:![图片说明](https://img-ask.csdn.net/upload/201604/02/1459603192_651468.png) 这是onPictureToken方法的实现方法: ``` private Camera.PictureCallback mPictureCallback=new Camera.PictureCallback() { @Override public void onPictureTaken(byte[] data, Camera camera) { //将数据写入SD卡的temp.png文件当中 File tempFile=new File("/sdcard/temp.png"); try { FileOutputStream fileOutputStream=new FileOutputStream(tempFile); fileOutputStream.write(data); fileOutputStream.close(); Intent intent=new Intent(CustomCamera.this,ResultAty.class); intent.putExtra("picPath",tempFile.getAbsolutePath()); startActivity(intent); CustomCamera.this.finish(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }; ``` 跳转到另一个activity来进行显示图片: ``` String path=getIntent().getStringExtra("picPath"); ImageView imageView= (ImageView) findViewById(R.id.pic); //对图像的显示角度进行调整 try { FileInputStream fis=new FileInputStream(path); //把图像转换成字节流 Bitmap bitmap=BitmapFactory.decodeStream(fis); Matrix matrix=new Matrix(); matrix.setRotate(90); //调整角度 bitmap=Bitmap.createBitmap(bitmap,0,0,bitmap.getWidth(),bitmap.getHeight(),matrix,true); imageView.setImageBitmap(bitmap); } catch (FileNotFoundException e) { e.printStackTrace(); } } ``` 麻烦各位大神给个提示,我自己debug了很久都没有找出问题所在,谢谢!

怎么用dcm4che 把dcm格式的图片转成jpg格式啊?

我的代码如下: ``` import java.io.File; import java.io.IOException; import org.dcm4che3.tool.dcm2jpg.Dcm2Jpg; import org.junit.Test; public class TestDcm2jpg { @Test public void testDcm2jpg2(){ try{ File src = new File("E:/影像实例/1/1.2.392.200036.9123.100.11.12.200000000.2013052710593606.dcm"); File dest = new File("E:/影像实例/1/1.2.392.200036.9123.100.11.12.200000000.2013052710593606.jpg"); Dcm2Jpg dcm2jpg= new Dcm2Jpg(); dcm2jpg.convert(src, dest); System.out.println("Completed"); } catch(IOException e){ e.printStackTrace(); } catch(Exception e){ e.printStackTrace(); } } } ``` 运行的时候抛了空指针错误: ``` java.lang.NullPointerException at org.dcm4che3.tool.dcm2jpg.Dcm2Jpg.writeImage(Dcm2Jpg.java:402) at org.dcm4che3.tool.dcm2jpg.Dcm2Jpg.convert(Dcm2Jpg.java:364) at com.boco.test.dcm2jpg.TestDcm2jpg.testDcm2jpg2(TestDcm2jpg.java:27) 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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192) ```

OpenGL 用三角形扇绘制圆 报错GLUT Fatal Error: pixel format with necessary capabilities not

#include<GLTools.h> #include<GLShaderManager.h> #include<GL/glut.h> int g_width = 800; int g_height = 600; int nStep = 200; const GLfloat a = 0.6f, b = 0.3f; const GLfloat Pi = 3.1415926536f; GLShaderManager shaderManager; GLBatch pointBatch; GLBatch lineBatch; GLBatch lineStripBatch; GLBatch lineLoopBatch; GLBatch triangleBatch; GLBatch triangleStripBatch; GLBatch triangleFanBatch; void initialize(); void uninitialize(); void display_func(void); void reshape_func(int w, int h); void key_func(unsigned char key, int x, int y); void idle_func(); void initialize() { glClearColor(0.0, 0.0, 0.0, 1.0); glClearDepth(1.0); shaderManager.InitializeStockShaders(); GLfloat vCoast[24][3] = { {2.80,1.20,0.0},{2.0,1.20,0.0}, {2.0,1.08,0.0},{2.0,1.08,0.0}, {0.0,0.80,0.0},{-.40,0.40,0.0}, {-.48,0.2,0.0},{-.40,0.0,0.0}, {-.60,-.40,0.0},{-.80,-.80,0.0}, {-.80,-1.4,0.0},{-.40,-1.60,0.0}, {0.0,-1.20,0.0},{.2,-.80,0.0}, {.48,-.40,0.0},{.2,-.80,0.0}, {.48,.20,0.0},{.80,.40,0.0}, {1.20,.80,0.0},{1.60,.60,0.0}, {2.0,.60,0.0},{2.2,.80,0.0}, {2.40,1.0,0.0},{2.80,1.0,0.0} }; for (int i = 0; i < 24; i++) { vCoast[i][0] *= 0.3; vCoast[i][1] *= 0.3; vCoast[i][2] *= 0.3; } //Load point batch pointBatch.Begin(GL_POINT, 24); pointBatch.CopyVertexData3f(vCoast); pointBatch.End(); //Load as a bunch of line segments lineBatch.Begin(GL_LINES, 24); lineBatch.CopyVertexData3f(vCoast); lineBatch.End(); //Load as a single line segment lineStripBatch.Begin(GL_LINE_STRIP, 24); lineStripBatch.CopyVertexData3f(vCoast); lineStripBatch.End(); //Single line,connect first and last points lineLoopBatch.Begin(GL_LINE_LOOP, 24); lineLoopBatch.CopyVertexData3f(vCoast); lineLoopBatch.End(); GLfloat vPyramid[16][3] = {0}; float angle = 0; int i = 0; for (; angle < (2.0f*Pi)&&i<16; angle += (Pi / 8.0f),i++) { int x = 50.0f*sin(angle); int y = 50.f*cos(angle); vPyramid[i][1] = x; vPyramid[i][2] = y; vPyramid[i][3] = 0.0f; } //Load as a triangle fan triangleFanBatch.Begin(GL_TRIANGLE_FAN,16); triangleFanBatch.CopyVertexData3f(vPyramid); triangleFanBatch.End(); } void display_func(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glutSwapBuffers(); } void idle_func() { glutPostRedisplay(); } void reshape_func(int w, int h) { glViewport(0, 0, w, h); } void key_func(unsigned char key, int x, int y) { switch (key) { case 49: case 50: glLineWidth(2.0f); lineStripBatch.Draw(); glLineWidth(1.0f); break; case 51: glLineWidth(2.0f); lineLoopBatch.Draw(); glLineWidth(1.0f); break; case 52: glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); triangleBatch.Draw(); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); break; case 53: glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); triangleFanBatch.Draw(); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); break; case 54: glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); triangleStripBatch.Draw(); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); break; } } int main(int argc, char **argv) { glutInit(&argc, argv); glutInitWindowSize(g_width, g_height); glutInitDisplayMode(GLUT_DEPTH || GLUT_DOUBLE || GLUT_RGB); glutCreateWindow("MyShapes"); initialize(); GLenum err = glewInit(); if (GLEW_OK != err) { fprintf(stderr, "GLEW Error: $s\n", glewGetErrorString(err)); return 1; } glutDisplayFunc(display_func); glutReshapeFunc(reshape_func); glutKeyboardFunc(key_func); glutIdleFunc(idle_func); glutMainLoop(); return 0; }

android-appium: A new session could not be created

detail log: org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Command failed: C:\Windows\system32\cmd.exe /s /c “C:\Users\sxie\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 shell “ps ‘uiautomator’”” ) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 0 milliseconds Build info: version: ‘3.4.0’, revision: ‘unknown’, time: 'unknown’ System info: host: ‘WL00070299’, ip: ‘10.110.12.39’, os.name: ‘Windows 8.1’, os.arch: ‘x86’, os.version: ‘6.3’, java.version: '1.8.0_40’ Driver info: driver.version: AndroidDriver at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:215) at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:167) at io.appium.java_client.remote.AppiumProtocolHandShake.createSession(AppiumProtocolHandShake.java:161) at io.appium.java_client.remote.AppiumProtocolHandShake.createSession(AppiumProtocolHandShake.java:76) at io.appium.java_client.remote.AppiumCommandExecutor.doExecute(AppiumCommandExecutor.java:111) at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:162) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:637) at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42) at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1) at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:250) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:236) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:137) at io.appium.java_client.DefaultGenericMobileDriver.(DefaultGenericMobileDriver.java:38) at io.appium.java_client.AppiumDriver.(AppiumDriver.java:88) at io.appium.java_client.AppiumDriver.(AppiumDriver.java:112) at io.appium.java_client.android.AndroidDriver.(AndroidDriver.java:73) at com.sky.demo.ContactTest.setUp(ContactTest.java:44) 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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192) ========================================== 直接在cmd中执行"C:\Windows\system32\cmd.exe /s /c "C:\Users\sxie\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 shell "ps 'uiautomator'"" bad pid 'uiautomator'", 报错: bad pid 'uiautomator' =============================================================================== code: public class ContactTest { private AndroidDriver driver; @Before public void setUp() throws Exception { //设置apk的路径 File classpathRoot = new File(System.getProperty("user.dir")); File appDir = new File(classpathRoot, "apps"); File app = new File(appDir, "ContactManager.apk"); //设置自动化相关参数 DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability(CapabilityType.BROWSER_NAME, ""); capabilities.setCapability("automationName","Appium"); capabilities.setCapability("platformName", "Android"); capabilities.setCapability("deviceName", "Pixel_XL_API_25");// Galaxy_Nexus_API_25 capabilities.setCapability("noReset", true); capabilities.setCapability("avdReadyTimeout", 300000); capabilities.setCapability("sessionOverride", true); //设置安卓系统版本 capabilities.setCapability("platformVersion", "7.1.1"); //设置apk路径 capabilities.setCapability("app", app.getAbsolutePath()); //设置app的主包名和主类名 capabilities.setCapability("appPackage", "com.example.android.contactmanager"); capabilities.setCapability("appActivity", ".ContactManager"); //初始化 driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities); driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS); } @Test public void addContact(){ WebElement el = driver.findElement(By.name("Add Contact")); el.click(); List<WebElement> textFieldsList = driver.findElementsByClassName("android.widget.EditText"); textFieldsList.get(0).sendKeys("feimaoyuzhubaobao"); textFieldsList.get(2).sendKeys("forever together"); driver.swipe(100, 500, 100, 100, 2); driver.findElementByName("Save").click(); } @After public void tearDown() throws Exception { driver.quit(); } }

android中从位图获取getPixels

代码: BitmapFactory.Options options = new BitmapFactory.Options(); Bitmap b = BitmapFactory.decodeResource(getResources(), R.drawable.test, options); int[] pixels = new int[1]; if(b != null){ pixels = new int[b.getHeight()*b.getWidth()]; b.getPixels(pixels, 0, b.getWidth(), 0, 0, b.getWidth(), b.getHeight()); for(int i = 0 ; i < 100 ; i++){ Log.d("test","Pixel is :"+pixels[i]); } } 其中R.drawable.test是 .bmp 文件,位于res/drawable-nodp中 我期盼的结果不是0-255这些数值。 06-03 21:49:24.364: D/test(4088): Pixel is :-16777088 06-03 21:49:24.364: D/test(4088): Pixel is :-16777088 06-03 21:49:24.364: D/test(4088): Pixel is :-16777088 06-03 21:49:24.364: D/test(4088): Pixel is :-16777088 06-03 21:49:24.364: D/test(4088): Pixel is :-16777088 06-03 21:49:24.364: D/test(4088): Pixel is :-16777088 06-03 21:49:24.374: D/test(4088): Pixel is :-16777088 数字不对,请高手帮忙。

C中在结构体中嵌套一个联合体,java中应该如何处理?大家帮我看看这样写对不对,还有调用的时候!

C语言: ``` typedef struct { u16 Command; union { CImage Image; CSensor Sensor; CEdgeChkData EdgeData; } Contact; } CSensorPkg; ``` java: ``` public class CSensorPkg{ public CSensorPkg(short command) { super(); Command = command; } private short Command; public class Contact{ public Contact(CImage image, CSensor sensor, CEdgeChkData edgeData) { super(); Image = image; Sensor = sensor; EdgeData = edgeData; } CImage Image; CSensor Sensor; CEdgeChkData EdgeData; } } ``` 我要调用的时候:PixelCount = receive_data.Contact.EdgeData.Count;老是报错,这是为什么呢?

Java 运行时异常,java.lang.NullPointerException

最近在刚刚学Java,刚刚学完继承和多态,现在在做一个作业遇到了困难。 我简单的说一下,父类Vegetable,子类Tomato继承父类,子类有构造方法Tomato(String name,boolean isProtected,Date d) 这是父类Vegetable的定义: ``` package Pixel; import java.util.Date; public class Vegetable { String name; public int SerialNumber;//每个植物的序列号 public int productivity; static int id=0; Date WhentoGrow; public Vegetable(String name) { this.name=name; id++; } } ``` 子类: ``` package Pixel; import java.text.SimpleDateFormat; import java.text.DecimalFormat; import java.util.Date; public class Tomato extends Vegetable { boolean isProtected=true; public Tomato(String name,boolean Protected,Date d) { super(name); this.WhentoGrow=d; this.SerialNumber=super.id; isProtected=Protected; if(isProtected)productivity=10; else productivity=5; } private long GrowCycle=6*3600*1000 ;//一个番茄长6小时长出 SimpleDateFormat When = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); final long millis=WhentoGrow.getTime(); final long harvestmillis=millis+GrowCycle; } ``` 在另一个class中做测试: ``` package Pixel; import java.util.Date; public class test { @SuppressWarnings("deprecation") public static void main(String []args) { Date t1=new Date(120,4,3,19,30,00); Date t2=new Date(120,4,3,19,30,00); //System.out.println(t1.getTime()); Tomato fanqie=new Tomato("fanqie",true,t1); Tomato fanqie2=new Tomato("fanqie",false,t2); } } ``` 通过t1t2做参数d来构造番茄1,番茄二,编辑器此时没有报错,但是当我运行的时候他就报错了,错误信息是java.lang.NullPointerException,并提示问题语句在于Tomato 文件里面的this.WhentoGrow=d这句话。 上网查过了,基本上就是说某个类没有具体实例化,但是我这里的t1,t2都应new过了啊 真的很苦恼,求大神指教啊!

将图像加载到 Bitmap 对象时出现内存不足的问题

<div class="post-text" itemprop="text"> <p>I have a list view with a couple of image buttons on each row. When you click the list row, it launches a new activity. I have had to build my own tabs because of an issue with the camera layout. The activity that gets launched for result is a map. If I click on my button to launch the image preview (load an image off the SD card) the application returns from the activity back to the <code>listview</code> activity to the result handler to relaunch my new activity which is nothing more than an image widget. </p> <p>The image preview on the list view is being done with the cursor and <code>ListAdapter</code>. This makes it pretty simple, but I am not sure how I can put a resized image (I.e. Smaller bit size not pixel as the <code>src</code> for the image button on the fly. So I just resized the image that came off the phone camera.</p> <p>The issue is that I get an out of memory error when it tries to go back and re-launch the 2nd activity.</p> <ul> <li>Is there a way I can build the list adapter easily row by row, where I can resize on the fly (<em>bit wise</em>)? </li> </ul> <p>This would be preferable as I also need to make some changes to the properties of the widgets/elements in each row as I am unable to select a row with touch screen because of focus issue. (<em>I can use roller ball.</em>)</p> <ul> <li>I know I can do an out of band resize and save of my image, but that is not really what I want to do, but some sample code for that would be nice.</li> </ul> <p>As soon as I disabled the image on the list view it worked fine again.</p> <p>FYI: This is how I was doing it:</p> <pre><code>String[] from = new String[] { DBHelper.KEY_BUSINESSNAME,DBHelper.KEY_ADDRESS,DBHelper.KEY_CITY,DBHelper.KEY_GPSLONG,DBHelper.KEY_GPSLAT,DBHelper.KEY_IMAGEFILENAME + ""}; int[] to = new int[] {R.id.businessname,R.id.address,R.id.city,R.id.gpslong,R.id.gpslat,R.id.imagefilename }; notes = new SimpleCursorAdapter(this, R.layout.notes_row, c, from, to); setListAdapter(notes); </code></pre> <p>Where <code>R.id.imagefilename</code> is a <code>ButtonImage</code>.</p> <p>Here is my LogCat:</p> <pre><code>01-25 05:05:49.877: ERROR/dalvikvm-heap(3896): 6291456-byte external allocation too large for this process. 01-25 05:05:49.877: ERROR/(3896): VM wont let us allocate 6291456 bytes 01-25 05:05:49.877: ERROR/AndroidRuntime(3896): Uncaught handler: thread main exiting due to uncaught exception 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): java.lang.OutOfMemoryError: bitmap size exceeds VM budget 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.graphics.BitmapFactory.nativeDecodeStream(Native Method) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:304) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:149) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:174) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.graphics.drawable.Drawable.createFromPath(Drawable.java:729) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.widget.ImageView.resolveUri(ImageView.java:484) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.widget.ImageView.setImageURI(ImageView.java:281) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.widget.SimpleCursorAdapter.setViewImage(SimpleCursorAdapter.java:183) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.widget.SimpleCursorAdapter.bindView(SimpleCursorAdapter.java:129) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.widget.CursorAdapter.getView(CursorAdapter.java:150) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.widget.AbsListView.obtainView(AbsListView.java:1057) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.widget.ListView.makeAndAddView(ListView.java:1616) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.widget.ListView.fillSpecific(ListView.java:1177) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.widget.ListView.layoutChildren(ListView.java:1454) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.widget.AbsListView.onLayout(AbsListView.java:937) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.view.View.layout(View.java:5611) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1119) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.widget.LinearLayout.layoutHorizontal(LinearLayout.java:1108) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.widget.LinearLayout.onLayout(LinearLayout.java:922) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.view.View.layout(View.java:5611) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.widget.FrameLayout.onLayout(FrameLayout.java:294) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.view.View.layout(View.java:5611) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1119) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:999) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.widget.LinearLayout.onLayout(LinearLayout.java:920) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.view.View.layout(View.java:5611) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.widget.FrameLayout.onLayout(FrameLayout.java:294) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.view.View.layout(View.java:5611) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.view.ViewRoot.performTraversals(ViewRoot.java:771) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.view.ViewRoot.handleMessage(ViewRoot.java:1103) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.os.Handler.dispatchMessage(Handler.java:88) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.os.Looper.loop(Looper.java:123) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.app.ActivityThread.main(ActivityThread.java:3742) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at java.lang.reflect.Method.invokeNative(Native Method) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at java.lang.reflect.Method.invoke(Method.java:515) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:497) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at dalvik.system.NativeStart.main(Native Method) 01-25 05:10:01.127: ERROR/AndroidRuntime(3943): ERROR: thread attach failed </code></pre> <p>I also have a new error when displaying an image: </p> <pre><code>01-25 22:13:18.594: DEBUG/skia(4204): xxxxxxxxxxx jpeg error 20 Improper call to JPEG library in state %d 01-25 22:13:18.604: INFO/System.out(4204): resolveUri failed on bad bitmap uri: 01-25 22:13:18.694: ERROR/dalvikvm-heap(4204): 6291456-byte external allocation too large for this process. 01-25 22:13:18.694: ERROR/(4204): VM won't let us allocate 6291456 bytes 01-25 22:13:18.694: DEBUG/skia(4204): xxxxxxxxxxxxxxxxxxxx allocPixelRef failed </code></pre> </div> <p>转载于:https://stackoverflow.com/questions/477572/strange-out-of-memory-issue-while-loading-an-image-to-a-bitmap-object</p>

想问一下c语言中的->指针,在java中怎么应用的?举例如下:

C语言中:ImageCount = receive_data->Contact.Image.PixelCnt; (receive_data是指针,Contact是自定义的联合体);我在java中如何表示 我这样写的,但是报错: PixelCount = receive_data.Contact.EdgeData.Count; 求指导,感激不尽!!!

android如何获取屏幕正是宽高像素?

今天想做适配,突然发现通过代码获取的宽高不太对劲 1080x1920的手机,3120x1440的手机,2880x1440的手机,获取到的宽度均为1080,高度虽然不一样但也和手机参数不一致。应该如何正确获取宽高参数? 尝试过的代码如下 一 WindowManager wm = (WindowManager) this.getSystemService(Context.WINDOW_SERVICE); DisplayMetrics dm = new DisplayMetrics(); wm.getDefaultDisplay().getMetrics(dm); width = dm.widthPixels; height = dm.heightPixels; 二 playMetrics outMetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getRealMetrics(outMetrics); int width = outMetrics.widthPixels; int height

PyQt5如何获取鼠标处图片像素

如题,我搜到了PyQt4的写法,想改成5的,但是5的函数变了,不太会,不知道5里鼠标处的Wid怎么获取? 这个是4的实现方法 PS:5不支持QPixmap.grabWindow,改成了Qscreen.grabWindow, 然后第一个参数Wid用QApplication.desktop().winId()也无法获取了,暂时还没有找到获取方式 ``` if event.buttons() & Qt.LeftButton: pointX = event.globalX() pointY = event.globalY() # img is QImage type img = QPixmap.grabWindow( QApplication.desktop().winId()).toImage() rgb = img.pixel(pointX, pointY) #十进制 red10 = QtGui.qRed(rgb) green10 =QtGui.qGreen(rgb) blue10 = QtGui.qBlue(rgb) color10="("+str(red10)+","+str(green10)+","+str(blue10)+")" #十六进制 #print str(hex(red10)) red16=str(hex(red10))[2:] green16=str(hex(green10))[2] blue16=str(hex(blue10))[2:] color16=red16+green16+blue16 #print color16 print "(%s,%s) = %s (%s,%s,%s)" % (pointX, pointY, color16,red10, green10, blue10) self.label.setText("(%s,%s) = %s (%s,%s,%s)" % (pointX, pointY, color16,red10, green10, blue10)) #该片段来自于http://outofmemory.cn ``` 代码来源 http://outofmemory.cn/code-snippet/12666/PyQt4-get-screen-position-color

获取屏幕尺寸,以像素为单位

<div class="post-text" itemprop="text"> <p>I created some custom elements, and I want to programmatically place them to the upper right corner (<code>n</code> pixels from the top edge and <code>m</code> pixels from the right edge). Therefore I need to get the screen width and screen height and then set position:</p> <pre><code>int px = screenWidth - m; int py = screenHeight - n; </code></pre> <p>How do I get <code>screenWidth</code> and <code>screenHeight</code> in the main Activity?</p> </div> <p>转载于:https://stackoverflow.com/questions/1016896/get-screen-dimensions-in-pixels</p>

java.lang.ClassCastException异常

java.lang.ClassCastException: com.ysb.system.project.monitor.online.domain.OnlineSession cannot be cast to com.ysb.system.project.monitor.online.domain.OnlineSession ![图片说明](https://img-ask.csdn.net/upload/201907/26/1564123585_391342.png) 请问各位大神遇到过这样的强转问题吗?

mybatis中mapper配置问题

第一次创建,报一下这些错误,求解决!求解决!不知道usermapper哪里出问题 D:\Java\jdk1.8.0_172\bin\java.exe "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2018.1.5\lib\idea_rt.jar=58476:C:\Program Files\JetBrains\IntelliJ IDEA 2018.1.5\bin" -Dfile.encoding=UTF-8 -classpath D:\Java\jdk1.8.0_172\jre\lib\charsets.jar;D:\Java\jdk1.8.0_172\jre\lib\deploy.jar;D:\Java\jdk1.8.0_172\jre\lib\ext\access-bridge-64.jar;D:\Java\jdk1.8.0_172\jre\lib\ext\cldrdata.jar;D:\Java\jdk1.8.0_172\jre\lib\ext\dnsns.jar;D:\Java\jdk1.8.0_172\jre\lib\ext\jaccess.jar;D:\Java\jdk1.8.0_172\jre\lib\ext\jfxrt.jar;D:\Java\jdk1.8.0_172\jre\lib\ext\localedata.jar;D:\Java\jdk1.8.0_172\jre\lib\ext\nashorn.jar;D:\Java\jdk1.8.0_172\jre\lib\ext\sunec.jar;D:\Java\jdk1.8.0_172\jre\lib\ext\sunjce_provider.jar;D:\Java\jdk1.8.0_172\jre\lib\ext\sunmscapi.jar;D:\Java\jdk1.8.0_172\jre\lib\ext\sunpkcs11.jar;D:\Java\jdk1.8.0_172\jre\lib\ext\zipfs.jar;D:\Java\jdk1.8.0_172\jre\lib\javaws.jar;D:\Java\jdk1.8.0_172\jre\lib\jce.jar;D:\Java\jdk1.8.0_172\jre\lib\jfr.jar;D:\Java\jdk1.8.0_172\jre\lib\jfxswt.jar;D:\Java\jdk1.8.0_172\jre\lib\jsse.jar;D:\Java\jdk1.8.0_172\jre\lib\management-agent.jar;D:\Java\jdk1.8.0_172\jre\lib\plugin.jar;D:\Java\jdk1.8.0_172\jre\lib\resources.jar;D:\Java\jdk1.8.0_172\jre\lib\rt.jar;D:\workplace\webssm\target\classes;D:\mavenRepository\jstl\jstl\1.2\jstl-1.2.jar;D:\mavenRepository\javax\javaee-api\7.0\javaee-api-7.0.jar;D:\mavenRepository\com\sun\mail\javax.mail\1.5.0\javax.mail-1.5.0.jar;D:\mavenRepository\javax\activation\activation\1.1\activation-1.1.jar;D:\mavenRepository\org\mybatis\mybatis\3.3.0\mybatis-3.3.0.jar;D:\mavenRepository\mysql\mysql-connector-java\5.1.29\mysql-connector-java-5.1.29.jar;D:\mavenRepository\commons-dbcp\commons-dbcp\1.2.2\commons-dbcp-1.2.2.jar;D:\mavenRepository\commons-pool\commons-pool\1.3\commons-pool-1.3.jar;D:\mavenRepository\com\alibaba\fastjson\1.1.41\fastjson-1.1.41.jar;D:\mavenRepository\log4j\log4j\1.2.17\log4j-1.2.17.jar;D:\mavenRepository\org\slf4j\slf4j-api\1.7.18\slf4j-api-1.7.18.jar;D:\mavenRepository\org\slf4j\slf4j-log4j12\1.7.18\slf4j-log4j12-1.7.18.jar;D:\mavenRepository\org\codehaus\jackson\jackson-mapper-asl\1.9.13\jackson-mapper-asl-1.9.13.jar;D:\mavenRepository\org\codehaus\jackson\jackson-core-asl\1.9.13\jackson-core-asl-1.9.13.jar;D:\mavenRepository\com\fasterxml\jackson\core\jackson-core\2.8.0\jackson-core-2.8.0.jar;D:\mavenRepository\com\fasterxml\jackson\core\jackson-databind\2.8.0\jackson-databind-2.8.0.jar;D:\mavenRepository\com\fasterxml\jackson\core\jackson-annotations\2.8.0\jackson-annotations-2.8.0.jar;D:\mavenRepository\commons-fileupload\commons-fileupload\1.3.1\commons-fileupload-1.3.1.jar;D:\mavenRepository\commons-io\commons-io\2.4\commons-io-2.4.jar;D:\mavenRepository\commons-codec\commons-codec\1.9\commons-codec-1.9.jar com.controller.test Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException: ### Error building SqlSession. ### The error may exist in com/mapper/UserMapper.java (best guess) ### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error creating document instance. Cause: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 43; 文档根元素 "mapper" 必须匹配 DOCTYPE 根 "null"。 at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30) at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:54) at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:38) at com.controller.test.main(test.java:25) Caused by: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error creating document instance. Cause: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 43; 文档根元素 "mapper" 必须匹配 DOCTYPE 根 "null"。 at org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:115) at org.apache.ibatis.builder.xml.XMLConfigBuilder.parse(XMLConfigBuilder.java:95) at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:52) ... 2 more Caused by: org.apache.ibatis.builder.BuilderException: Error creating document instance. Cause: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 43; 文档根元素 "mapper" 必须匹配 DOCTYPE 根 "null"。 at org.apache.ibatis.parsing.XPathParser.createDocument(XPathParser.java:259) at org.apache.ibatis.parsing.XPathParser.<init>(XPathParser.java:125) at org.apache.ibatis.builder.xml.XMLMapperBuilder.<init>(XMLMapperBuilder.java:78) at org.apache.ibatis.builder.xml.XMLMapperBuilder.<init>(XMLMapperBuilder.java:73) at org.apache.ibatis.builder.annotation.MapperAnnotationBuilder.loadXmlResource(MapperAnnotationBuilder.java:166) at org.apache.ibatis.builder.annotation.MapperAnnotationBuilder.parse(MapperAnnotationBuilder.java:118) at org.apache.ibatis.binding.MapperRegistry.addMapper(MapperRegistry.java:72) at org.apache.ibatis.session.Configuration.addMapper(Configuration.java:671) at org.apache.ibatis.builder.xml.XMLConfigBuilder.mapperElement(XMLConfigBuilder.java:348) at org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:113) ... 4 more Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 43; 文档根元素 "mapper" 必须匹配 DOCTYPE 根 "null"。 <mapper namespace="com.mapper.UserMapper"> <resultMap type="com.pojo.User" id="userResultMap"> <id property="id" colum="id"/> <result property="username" column="username"/> <result property="sex" column="sex"/> <result property="age" column="age"/> <result property="loginname" column="loginname"/> <result property="password" column="password"/> <result property="phone" column="phone"/> <result property="address" column="address"/> <!-- 一对多关联映射--> <collection property="orders" javaType="ArrayList" column="id" ofType="com.pojo.User" select="com.mapper.OrderMapper.selectOrderByUserId" fetchType="lazy"> <id property="id" colum="id"></id> <result property="code" column="code"></result> <result property="total" column="total"></result> </collection> </resultMap> <select id="selectUserById" parameterType="int" resultMap="userResultMap"> SELECT * FROM user WHERE id = #{id} </select> </mapper> package com.controller; import com.mapper.OrderMapper; import com.mapper.UserMapper; import com.pojo.Order; import com.pojo.User; import org.apache.ibatis.io.Resources; import org.apache.ibatis.session.*; //import org.mybatis.spring.SqlSessionFactoryBean; //import org.springframework.aop.scope.ScopedProxyUtils; import java.io.IOException; //import java.io.InputStream; import java.io.Reader; import java.util.List; public class test { public static void main(String[] args) throws IOException { //读取mybatis-config.xml文件 //InputStream inputStream= Resources.getResourceAsStream("mybatis-config.xml"); Reader reader=Resources.getResourceAsReader("mybatis-config.xml"); //初始化mybatis,创建sqlsessionfactory类的实例 SqlSessionFactory sqlSessionFactory=new SqlSessionFactoryBuilder().build(reader); //创建Session实例 SqlSession session=sqlSessionFactory.openSession(); test t=new test(); t.testSelectUserById(session); t.testSelectOrderById(session); session.commit(); session.close(); } //测试一对多关系 public void testSelectUserById(SqlSession session){ //获得usermapper接口的代理对象 UserMapper um=session.getMapper(UserMapper.class); //调用selectUserById方法 User user=um.selectUserById(1); //查询user的对象信息 System.out.println(user.getId()+""+user.getUsername()); List<Order> orders=user.getOrders(); for (Order order:orders ) { System.out.println(order); } } //测试多对多的关系,查询订单Order的时候级联查询订单的商品 public void testSelectOrderById(SqlSession session){ //获得OrderMapper接口的代理对象 OrderMapper om=session.getMapper(OrderMapper.class); //调用selectOrderById方法 Order order=om.selectOrderById(2); //查看查询到的信息 System.out.println(order.getId()+""+order.getCode()+""+order.getTotal()); User user=order.getUser(); System.out.println(user); } }

在Java和PHP中获取RGB有不同的结果

<div class="post-text" itemprop="text"> <p>i want to get RGB code for each pixel. As example i took pixel(0,0) (corner left). <strong>I load JPEG image and then store in Bitmap object in Java</strong>. For experiment i attach the image for example :</p> <p><a href="https://i.stack.imgur.com/NRiXj.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NRiXj.jpg" alt="enter image description here"></a></p> <p>I take RGB with PHP and Java. Here the code :</p> <p><strong>Java (rgbImage is Bitmap object which loaded from JPEG file) :</strong></p> <pre><code>int width = rgbImage.getWidth(); int height = rgbImage.getHeight(); for (int x = 0; x &lt; rgbImage.getWidth(); x++){ for (int y = 0; y &lt; rgbImage.getHeight(); y++) { int pixel = rgbImage.getPixel(x, y); double red = Color.red(pixel); double green = Color.green(pixel); double blue = Color.blue(pixel); if(x == 0 &amp;&amp; y == 0){ System.out.println("red : "+red+" green : "+green+" blue : "+blue); } </code></pre> <p><strong>PHP :</strong></p> <pre><code> $rgbImage = imagecreatefromjpeg("$path"); $width = imagesx($rgbImage); $height = imagesy($rgbImage); for($x = 0 ; $x &lt; $width ; $x++){ for($y = 0 ; $y &lt; $height ; $y++){ $rgb = imagecolorat($rgbImage, $x, $y); $r = ($rgb &gt;&gt; 16) &amp; 0xFF; $g = ($rgb &gt;&gt; 8) &amp; 0xFF; $b = $rgb &amp; 0xFF; if($x == 0 &amp;&amp; $y == 0){ echo("r : $r , g : $g, b : $b &lt;br/&gt;"); } } } </code></pre> <p><strong>And the result both of them are :</strong></p> <p>JAVA : I/System.out: red : 91.0 green : 91.0 blue : 101.0</p> <p>PHP : r : 93 , g : 91, b : 102 </p> <p><strong>The Main Question is :</strong></p> <p>Why with the same image, two methods above can give different result?</p> </div>

JAVA怎么让图片翻转?

我想点击按钮就让图片翻转。可是只能翻转一次是怎么回事//// =============== -------- 这里点按钮只能翻转一次,然后再点就不变了 ![图片说明](https://img-ask.csdn.net/upload/201911/06/1573053787_868928.jpg) 代码 ------------- ------------ ``` public class My4 extends JFrame{ public My4() { setVisible(true); setBounds(0, 100, 500, 400); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setTitle("图像翻转"); add(new MyPanels()); validate(); } //------------------------------------------------------------- public static void main(String[] args) { // TODO Auto-generated method stub new My4(); } } class MyPanels extends JPanel implements ActionListener{ private int w;//图片长度 private int h;//图片宽 BufferedImage image; JButton button1; Graphics2D g2; boolean change=false; public MyPanels() { button1=new JButton("翻转"); add(button1); button1.addActionListener(this); try { image=ImageIO.read(new File("D:\\素材\\恐龙1.png")); w=image.getWidth(); h=image.getHeight(); } catch (IOException e) { e.printStackTrace(); } } @Override public void paint(Graphics g) { // TODO Auto-generated method stub int t=1; super.paint(g); g2=(Graphics2D) g; if(!change) { g2.drawImage(image, 30, 30, w, h, this); } //shx:水平方向的倾斜量; shy:垂直方向的倾斜量。 //p.shear(0.3, 0); //g2.drawImage(image, p, this); //图像向X轴移动10px,Y轴移动50px //tr.translate(40, 50); //旋转30度 //tr.rotate(30*3.14159/180); //System.out.println(change); else { //是这里有问题吗 System.out.println("改"); AffineTransform p = new AffineTransform(); p.scale(-1,1); //向反反向缩放-1 p.translate(-(w+60), 0); g2.setTransform(p); g2.drawImage(image, 30, 30, w, h, this); } } //实现接口 @Override public void actionPerformed(ActionEvent e) { if(e.getSource()==button1) { change=true; repaint(); } } } ```

大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了

大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...

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

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

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

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

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

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

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

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

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

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

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

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

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

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

程序员写出这样的代码,能不挨骂吗?

当你换槽填坑时,面对一个新的环境。能够快速熟练,上手实现业务需求是关键。但是,哪些因素会影响你快速上手呢?是原有代码写的不够好?还是注释写的不够好?昨夜...

我说我不会算法,阿里把我挂了。

不说了,字节跳动也反手把我挂了。

带了6个月的徒弟当了面试官,而身为高级工程师的我天天修Bug......

即将毕业的应届毕业生一枚,现在只拿到了两家offer,但最近听到一些消息,其中一个offer,我这个组据说客户很少,很有可能整组被裁掉。 想问大家: 如果我刚入职这个组就被裁了怎么办呢? 大家都是什么时候知道自己要被裁了的? 面试软技能指导: BQ/Project/Resume 试听内容: 除了刷题,还有哪些技能是拿到offer不可或缺的要素 如何提升面试软实力:简历, 行为面试,沟通能...

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

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

C语言的灵魂之指针

指针在C语言中非常的重要,也比较的难。你对指针的掌握程度也决定了你对C语言的掌握程度。在学习C语言的时候因当搞清楚取值运算符和取地址运算符各自的含义。我们这里就通过取值运算符和取地址运算符展开讲指针。

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

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

10个提升效率的编程好习惯

文章目录00、前言01、双屏02、手机静音03、只学一个 00、前言 最近有读者反映学习编程困难,想放弃,询问是不是真的有不适合编程的人?我结合最近自己的学习经历和思考以及最近在数据结构与算法的折磨下得出的一些心得。 唐代大臣魏徵的【谏太宗十思疏】中写道,“善始者实繁,克终者盖寡”。大概的意思是:如果有好多人同时做一件事情,善于开始去做的人是非常多的,但是能够把这件事做好的人就寥寥无几了。 这句千...

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

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

面试:第十六章:Java中级开发

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

《Java经典编程365例》000:学妹的优秀成绩单

内容导航: 1、题目 2、代码实现 2.1、Student类 2.2、测试类Client 2.3、输出结果 前言 这是一个真实的故事,就发生在CSDN…其它学弟学妹开始抄吧! 1、题目 新建一个学生(Student),成员变量(属性)有: 姓名 性别 年龄(int) 成绩(double) 成员方法有两个: print()方法 功能为:输出名字 + 性别 + 年龄。

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

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

Python爬虫,高清美图我全都要(彼岸桌面壁纸)

爬取彼岸桌面网站较为简单,用到了requests、lxml、Beautiful Soup4

无代码时代来临,程序员如何保住饭碗?

编程语言层出不穷,从最初的机器语言到如今2500种以上的高级语言,程序员们大呼“学到头秃”。程序员一边面临编程语言不断推陈出新,一边面临由于许多代码已存在,程序员编写新应用程序时存在重复“搬砖”的现象。 无代码/低代码编程应运而生。无代码/低代码是一种创建应用的方法,它可以让开发者使用最少的编码知识来快速开发应用程序。开发者通过图形界面中,可视化建模来组装和配置应用程序。这样一来,开发者直...

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

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

6年开发经验女程序员,面试京东Java岗要求薪资28K

写在开头: 上周面试了一位女程序员,上午10::30来我们部门面试,2B哥接待了她.来看看她的简历: 个人简历 个人技能: ● 熟悉spring mvc 、spring、mybatis 等框架 ● 熟悉 redis 、rocketmq、dubbo、zookeeper、netty 、nginx、tomcat、mysql。 ● 阅读过juc 中的线程池、锁的源...

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

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

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

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

Java岗开发3年,公司临时抽查算法,离职后这几题我记一辈子

前几天我们公司做了一件蠢事,非常非常愚蠢的事情。我原以为从学校出来之后,除了找工作有测试外,不会有任何与考试有关的事儿。 但是,天有不测风云,公司技术总监、人事总监两位大佬突然降临到我们事业线,叫上我老大,给我们组织了一场别开生面的“考试”。 那是一个风和日丽的下午,我翘着二郎腿,左手端着一杯卡布奇诺,右手抓着我的罗技鼠标,滚动着轮轴,穿梭在头条热点之间。 “淡黄的长裙~蓬松的头发...

都前后端分离了,咱就别做页面跳转了!统统 JSON 交互

文章目录1. 无状态登录1.1 什么是有状态1.2 什么是无状态1.3 如何实现无状态1.4 各自优缺点2. 登录交互2.1 前后端分离的数据交互2.2 登录成功2.3 登录失败3. 未认证处理方案4. 注销登录 这是本系列的第四篇,有小伙伴找不到之前文章,松哥给大家列一个索引出来: 挖一个大坑,Spring Security 开搞! 松哥手把手带你入门 Spring Security,别再问密...

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

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

程序员是做全栈工程师好?还是专注一个领域好?

昨天,有位大一的同学私信我,说他要做全栈工程师。 我一听,这不害了孩子么,必须制止啊。 谁知,讲到最后,更确定了他做全栈程序员的梦想。 但凡做全栈工程师的,要么很惨,要么很牛! 但凡很牛的,绝不是一开始就是做全栈的! 全栈工程师听起来好听,但绝没有你想象的那么简单。 今天听我来给你唠,记得帮我点赞哦。 一、全栈工程师的职责 如果你学习编程的目的只是玩玩,那随意,想怎么学怎么学。...

不要再到处使用 === 了

我们知道现在的开发人员都使用 === 来代替 ==,为什么呢?我在网上看到的大多数教程都认为,要预测 JavaScript 强制转换是如何工作这太复杂了,因此建议总是使用===。这些都...

立即提问
相关内容推荐