1 程序包org.junit不存在
- 原因
junit版本过低 - 解决
提高junit版本,如4.12
2 编码问题
File was loaded in the wrong encoding: 'UTF-8'
如下连环图修改:
3 @Override must override a superclass method
- 原因
编译器版本过低. - 解决
编译器修改为1.7及以上,添加pom.xml配置文件.
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
4 拦截未登录状态
@ModelAttribute
public void isLogin(HttpSession session, HttpServletRequest request) throws UserLoginNoException{
if(session.getAttribute("bruser") == null){
System.out.format("用户未登录base");
throw new UserLoginNoException("没有登录");
}
}
当用户未登录时,直接拦截null状态.
5 线程在flask请求前运行
* Detected change in '/home/xdq/xinPrj/python/huaweiVAS/VIS/camera-info/run.py', reloading
* Restarting with stat
* Debugger is active!
* Debugger PIN: 732-366-147
threading data return: None
threading return result: name:xiaohong
sex: male
127.0.0.1 - - [11/Oct/2019 15:15:49] "POST /api/data/crowd-counting-h HTTP/1.1" 200 -
在web框架flask中,使用了threading,但是,请求时,先整型线程,然后执行请求内容.
6 maven打包jar缺少主清单
- 打包jar
mvn package
- 解压jar包
jar -vxf test.jar
- MANIFEST.MF
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Built-By: xdq
Created-By: Apache Maven 3.6.1
Build-Jdk: 1.8.0_191
缺少Main-Class
- 添加pom.xml
<build>
<finalName>JavaFunctionTest</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>basic.datatype.datatest.OutputTest</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
- MANIFEST.MF
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Built-By: xdq
Class-Path: lib/json-lib-2.4-jdk15.jar lib/commons-beanutils-1.8.0.jar
lib/commons-collections-3.2.1.jar lib/commons-lang-2.5.jar lib/commo
ns-logging-1.1.1.jar lib/ezmorph-1.0.6.jar
Created-By: Apache Maven 3.6.1
Build-Jdk: 1.8.0_191
Main-Class: basic.datatype.datatest.OutputTest
- 完整pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>java.function.test</groupId>
<artifactId>JavaFunctionTest</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<classifier>jdk15</classifier>
</dependency>
</dependencies>
<build>
<finalName>JavaFunctionTest</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>basic.datatype.datatest.OutputTest</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
7 path
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
path取值方式:<%=path%>
path值:ssmPureBackend
如mvn新建项目:ssmPureBackend
8 引用类出现错误
错误的源文件: /home/java/javaWebTest/ssmPureBackend/src/main/java/com/websocket/fullversion/MsgSocketHandle.java
文件不包含类com.websocket.fullversion.MsgSocketHandle
请删除该文件或确保该文件位于正确的源路径子目录中
- 文件路径
├── src
│ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ └── websocket
│ │ │ ├── fullversion
│ │ │ │ ├── MsgSocketHandle.java
│ │ │ │ ├── WebSocketConfig.java
│ │ │ │ └── WebSocketHandshakeInterceptor.java
- 修改后文件路径
├── src
│ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ └── websocket
│ │ │ ├── MsgSocketHandle.java
│ │ │ ├── WebSocketConfig.java
│ │ │ └── WebSocketHandshakeInterceptor.java
原因:多了一层路径,读不到类;
解决:上移一层路径.
【参考文献】
[1]https://blog.csdn.net/qq_35136982/article/details/80780856
[2]https://blog.csdn.net/h70614959/article/details/41697189/
[3]http://www.it1352.com/902362.html