遇到的错误
1:Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
由于使用的mysql版本过高,换成低版本的
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.0.4</version>
</dependency>
2:十二月 15, 2017 6:39:05 下午 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet [springDispatcherServlet] in context with path [] threw exception [Handler dispatch failed; nested exception is java.lang.AbstractMethodError: com.mysql.jdbc.Connection.isValid(I)Z] with root cause
java.lang.AbstractMethodError: com.mysql.jdbc.Connection.isValid(I)Z
at org.apache.commons.dbcp2.DelegatingConnection.isValid(DelegatingConnection.java:918)
at org.apache.commons.dbcp2.PoolableConnection.validate(PoolableConnection.java:283)《数据库连接池》
at org.apache.commons.dbcp2.PoolableConnectionFactory.validateConnection(PoolableConnectionFactory.java:357)
at org.apache.commons.dbcp2.BasicDataSource.validateConnectionFactory(BasicDataSource.java:2307) 《数据源》
at org.apache.commons.dbcp2.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:2290)
at org.apache.commons.dbcp2.BasicDataSource.createDataSource(BasicDataSource.java:2039)
数据库连接池和数据源配置的不对。应该选择正确的数据库连接池和数据源配置。不同的数据库连接池对数据源的配置要求不同。
3:执行mysql提示:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '--college
create table liyafei(name varchar(39) not null)' at line 1
因为创建表时数据库有--college阻塞,去掉即可
4: 项目打成war,发布到tomcat,提示:FAIL - Application at context path /sp could not be started
5: unsupported major.minor varsion 52.0
需要用jdk8进行部署,高版本jdk编译的class不能在低版本下面运行
6:tomcat关闭错误提示
一月 21, 2018 9:17:44 上午 org.apache.catalina.startup.Catalina stopServer
严重: Could not contact localhost:8005. Tomcat may not be running.
一月 21, 2018 9:17:44 上午 org.apache.catalina.startup.Catalina stopServer
严重: Catalina.stop:
java.net.ConnectException: 拒绝连接 (Connection refused)
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:580)
at java.net.Socket.connect(Socket.java:529)
at java.net.Socket.<init>(Socket.java:429)
at java.net.Socket.<init>(Socket.java:209)
at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:499)
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.stopServer(Bootstrap.java:343)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:430)
是因为tomcat里面有错误的war包,导致关闭异常。
7:List每次只能添加一个元素,中间不能隔空元素。例如:如果一个空List添加 list.add(1,"li"); ,将会抛出异常
HTTP Status 500 - Request processing failed; nested exception is java.lang.IndexOutOfBoundsException: Index: 1, Size: 0
8:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '--COMMONT ????
sql文件里面加注解时,前面两个--要空一格才能加注解,否则提示错误
-- ----------------------------
-- Table structure for tb_settle_wallet
-- COMMONT 备注说明
-- ----------------------------
9:WEB-INF下面的东西在浏览器是不能访问的,需要通过映射才能访问到,WEB-INF是Java的WEB应用的安全目录。所谓安全就是客户端无法访问,只有服务端可以访问的目录。如果想在页面中直接访问其中的文件,必须通过web.xml文件对要访问的文件进行相应映射才能访问。例如: /html/** /WEB-INF/html/
10:问题描述:打包出现,非法字符:'\ufeff" 错误。
解决方案:
利用notePad++打开出现错误的页面,
选择标题栏的格式—-将以UTF-8格式编码修改成将以UTF-8 无BOM 格式编码。
至此,问题解决。
11;提示
[ERROR] /D:/Android/workspace1/ssmFrameworkIntergrate/src/main/java/vertxTest/SpringVerticle.java:[25,30] -source 1.7 中不支持 lambda 表达式
(请使用 -source 8 或更高版本以启用 lambda 表达式)
jdk版本过低,在pom.xml和properties>compile level中修改source为更高版本
12:创建vertx工程时,需要创建war工程,否则创建Router实例时,会提示 cannot access router, need static
13:如果有多个工程进行打包时,需要先将被依赖的工程变异maven install,将聚合工程中不需要的模块移除。一层一层打包才行,否则会提示 compile 错误,pay-java-common工程can't fount
14: gradle使用build构建工程时,提示
16:22:16: Executing task 'build'...
Cause: error in opening zip file
16:22:16: Task execution finished 'build'.
是因为zip文件被损坏,下载过程中终止等。到gradle.properties 中查看引入的zip包
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-all.zip
下载放入到C:\Users\lenovo\.gradle\wrapper\dists\gradle-4.0-bin\3p92xsbhik5vmig8i90n16yxc 文件中即可。
15:错误: 编码GBK的不可映射字符 ,解决方法,向出现错误提示的模块的build.gradle中添加
//tasks.withType(JavaCompile) {
// options.encoding = "UTF-8"
//}
或者
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
即可
16:一行末尾有多余的空格时,gradle build时会提示 u/300错误
17:执行
insert into 'T_PERMISSION' values (2,'pem1','a','pemission1'); 提示
Error executing INSERT statement. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''T_PERMISSION' values (2,'pem1','a','pemission1')' at line 1 - Connection: Connection: 1ms
是因为插入表时,表名不应该用' '引住。
改为
insert into T_PERMISSION values (2,'pem1','a','pemission1');
18: 执行数据库 db.sql文件时,是从光标所在的位置开始执行。
19: 进行查询时:http://localhost:9002/crm/services/customerService/customer/login?telephone=18888888888&password=123456 提示:
No message body writer has been found for class top.kylewang.crm.domain.Customer, ContentType: text/html
其实已经查询到数据,但是返回内容类型不对
需要在service中修改注解@Consumes为@Produces http://www.cnblogs.com/liyafei/p/8515319.html
20: 使用Java api 连接elasticsearch集群时提示: https://elasticsearch.cn/question/1203
org.elasticsearch.client.transport.TransportClientNodesService$SimpleNodeSampler doSample
信息: [Quincy Harker] failed to get node info for {#transport#-1}{127.0.0.1}{127.0.0.1:9300}, disconnecting...
NodeDisconnectedException[[][127.0.0.1:9300][cluster:monitor/nodes/liveness] disconnected]
本次错误是因为 工程中引入的maven elasticsearch依赖和 安装的elasticsearch版本不一致导致的。
21: elasticsearch 进行更新操作时提示:
java.util.concurrent.ExecutionException: RemoteTransportException[[node-1][127.0.0.1:9300][indices:data/write/update]]; nested: RemoteTransportException[[node-3][127.0.0.1:9302][indices:data/write/update[s]]]; nested: DocumentMissingException[[type][3]: document missing];
是因为更新的文档不存在,也就是前面的index,type,id都存在时,才能更新,否则只能创建。
22: service 发布服务,
@Path("/DetailDisplayService") public interface DetailDisplayService { /** * 查询商品根据Uid * @return */ @Path("/selectProductAndRecByUid") @GET @Produces({"application/xml", "application/json"}) //返回void用consumes List<Product> selectProductAndRecByUid(@QueryParam("uid") String uid); }
提示:
No message body writer has been found for class java.util.ArrayList, ContentType: application/xml
是因为List中的Product解析不成为xml 文件。需要在Product类上加上注解
@XmlRootElement(name="product")
提示:Caused by: com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
excel.pojo.Product没有无参数默认构造器。
需要在Product中加入无参构造函数。成功。
23:搭建elasticsearch集群报错 。http://blog.csdn.net/qq_24879495/article/details/77718032
[2018-03-12T20:38:27,032][INFO ][o.e.d.z.ZenDiscovery ] [node-2] failed to send join request to master [{node-1}{jhJ9LI7FTES64sR9CHbl2Q}{JiV5qs3tQWmI4WfvVMEIyw}{127.0.0.1}{127.0.0.1:9300}], reason [RemoteTransportException[[node-1][127.0.0.1:9300][internal:discovery/zen/join]]; nested: IllegalArgumentException[can't add node {node-2}{jhJ9LI7FTES64sR9CHbl2Q}{S_VSvtdJRNCcGCmVOZyXTQ}{127.0.0.1}{127.0.0.1:9301}, found existing node {node-1}{jhJ9LI7FTES64sR9CHbl2Q}{JiV5qs3tQWmI4WfvVMEIyw}{127.0.0.1}{127.0.0.1:9300} with the same id but is a different node instance]; ]
复制elasticsearch之前,已经在data中产生数据,删除即可。
24 gradle build 时提示:
Could not set unknown property 'mainClassName' for project ':shop_background' of type org.gradle.api.Project.
解决:需要添加插件。
apply plugin: 'application'
然后提示
mainClassName no value. 为应用指定一个主类
mainClassName = "com.background.SpringBootBackgrouondMainClass"
25: 控制台提示: ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...
是因为 log4j的版本不对,将版本2.7 改为 2.10.0
'org.apache.logging.log4j:log4j-core:2.10.0'
错误消失
26:No message body writer has been found for class com.alibaba.fastjson.JSONObject, ContentType: */*
是因为通过service发布的服务,
cxf:
path: /services
servlet.init:
service-list-path: /info
jaxrs:
component-scan: true
cxf 不支持将对象直接解析
27: 提示:
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
是因为发送的url又映射到了原来的路径上。后台
@RequestMapping("/public") public String test3() { return "public"; }
28:
#{user.username} 但是从Mapper.java中传递的对象没有标明为user
在Mapper.java中参数标明user即可
int save(@Param("user") User user);
34: 在做数据库连接时要指定编码格式,否则会提示乱码。
spring.datasource.url = jdbc:mysql://localhost:3306/forum?useSSL=false&useUnicode=true&characterEncoding=UTF-8
35:idea打开maven工程,依赖包不添加,需要在右侧的maven中点击+ 添加工程pom.xml
36:idea中maven工程打包springboot项目,智能有一个springboot注解,要把test中的springboottest注解给去掉,才能打包成功。点击maven工程右边的install即可打包。
37:上传文件出现提示 org.springframework.web.multipart.MultipartException: Current request is not a multipart request
需要在body上传类型中选择 form-data,key选择File, value选择文件
向后台传输数据,可以在header中添加数据。后台通过request接收
38 启动项目提示:
Caused by: java.lang.IllegalArgumentException: 'script' must not be null or empty
因为项目启动时,sql脚本自动执行,需要将其注释掉。不能用--来注释。需要用
/*
*/
来注释
39: filezilla链接ftp服务器时提示:500 OOPS: vsftpd: refusing to run with writable root inside chroot ()错误的解决方法
当我们限定了用户不能跳出其主目录之后,使用该用户登录FTP时往往会遇到这个错误:
- 500 OOPS: vsftpd: refusing to run with writable root inside chroot ()
这个问题发生在最新的这是由于下面的更新造成的:
- - Add stronger checks for the configuration error of running with a writeable root directory inside a chroot(). This may bite people who carelessly turned on chroot_local_user but such is life.
从2.3.5之后,vsftpd增强了安全检查,如果用户被限定在了其主目录下,则该用户的主目录不能再具有写权限了!如果检查发现还有写权限,就会报该错误。
要修复这个错误,可以用命令chmod a-w /home/user去除用户主目录的写权限,注意把目录替换成你自己的。或者你可以在vsftpd的配置文件中增加下列两项中的一项:
allow_writeable_chroot=YES
#{page}*10,10 逗号不能少
select <include refid="Base_Column_List" /> from (select * from FtpPrivateFile where uploaduser=#{username})t1 limit #{page}*10,10
org.springframework.jdbc.BadSqlGrammarException:
### Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-10 10' at line 1
### The error may exist in file [D:\software\github\github下载\laboratoryWeb\labWeb\out\production\resources\mybatis\mapper\FtpFileMapper.xml]
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: select * from FtpPublicFile limit ? 10
应该将这种运算,交到servcie层
admin@iZwz92c0zpe8t65qe996ckZ:~$ service pure-ftpd start
Failed to start pure-ftpd.service: The name org.freedesktop.PolicyKit1 was notprovided by any .service files
See system logs and 'systemctl status pure-ftpd.service' for details.
admin@iZwz92c0zpe8t65qe996ckZ:~$ sudo service pure-ftpd start
sudo: unable to resolve host iZwz92c0zpe8t65qe996ckZ
43:下载的mysql插件版本号与电脑装的版本号不一致,将会提示 连接异常。
44:Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience
因为ajax请求设置为同步了,同步已经废弃,需要将
async: true, 设为true
45: 一些js脚本,某些浏览器不支持,所以执行不了。 例如:实验室网站,添加分类,删除分类功能,Google支持,Firefox不支持。
46:ckeditor 限制图片大小
已解决,
把ckeditor/plugins/image/dialogs/image.js中的
this.imageElement.getAttribute("style") || this.imageElement.removeAttribute("style");
改为
this.imageElement.setAttribute("style")&&this.imageElement.removeAttribute("style");
47:
select * from FtpPublicFile limit #{page},10 order by date_created DESC //出错,先后顺序不对
select * from FtpPublicFile order by date_created DESC limit #{page},10
48: ckeditor支持直接复制word文件。
//word格式
config.pasteFromWordRemoveFontStyles = false;
config.pasteFromWordRemoveStyles = false;
config.forcePasteAsPlainText =false;
config.pasteFromWordKeepsStructure = false;
config.pasteFromWordIgnoreFontFace = false;
config.pasteFilter=null; //粘贴过滤器设置为null 即可
48: ftp上传下载文件时,如果是zip文件,要用二进制流的形式,默认的是ascll码。
上传下载都要设置为二进制流, 否则提示文件错误,打不开。
FTPClient ftp = new FTPClient(); ftp.connect(host, port); // 如果采用默认端口,可以使用ftp.connect(host)的方式直接连接FTP服务器 ftp.login(username, password);// 登录 ftp.setFileType(FTPClient.BINARY_FILE_TYPE); //设置为二进制传输形式
49: 通过文件路径,去获取jar包下面resource/image下面的图片时。 因为打成jar包,不能通过文件路径获取了,只能通过流的方法 Inputstream 去获取文件。
ClassPathResource cpr = new ClassPathResource("./static/img/"+filename); String path1 = cpr.getPath(); System.out.println(path1); File file = cpr.getFile(); String path = file.getAbsolutePath(); //这种不行 FileInputStream fileInputStream = new FileInputStream(file); InputStream inputStream = cpr.getInputStream(); //通过这种方式。
错误提示:
cannot be resolved to absolute file path because it does not reside in the file system
50:开启缓存提示错误
.297 ERROR 17026 --- [ main] net.sf.ehcache.Cache : Unable to set localhost. This prevents creation of a GUID. Cause was: iZwz92c0zpe8t65qe996ckZ: iZwz92c0zpe8t65qe996ckZ: Name or servicenot known
java.net.UnknownHostException: iZwz92c0zpe8t65qe996ckZ: iZwz92c0zpe8t65qe996ckZ: Name or service not known
是因为localhost解析异常,将localhost的位置置换为不能解析的名字即可
编辑vi /etc/hosts
将127.0.0.1 localhost 改为:
127.0.0.1 iZwz92c0zpe8t65qe996ckZ