![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
java web
Zonson9999
但行好事,莫问前程
展开
-
maven 下载自动下载的jar包损坏的解决方法
错误提示如下:提示项目所依赖的 xz-1.0.jar包有问题,不能解析。解决方法:找到这个jar包所在的目录,也就是 /home/ubuntu/Repo/org/tukaanni第一步 把这个目录删除。第二步,回到eclipse执行一次 maven update即可修复问题。...原创 2021-10-05 17:27:20 · 1004 阅读 · 0 评论 -
Uncaught SyntaxError: Unexpected token ‘<‘
犯了了一个低级错误,浪费了半小时以上。现象:直接以文件方式打开index.html的时候,网页正常显示,console没有报错。以 http://127.0.0.1/ 方式运行后,网页无法加载,报错如上截图。原因:项目里有一个filter会对访问进行判断,有一些API需要登录后才能权限访问。新增一些目录时,需要在filter里增加一些白名单。这次加了js文件后,忘记添加白名单了。这个问题不能够直接看出来是这个原因导致的。所以如果有遇到相似的问题,请直接在浏览器试一下,是否..原创 2021-08-12 21:05:59 · 339 阅读 · 0 评论 -
springboot SchedulingConfigurer 问题记录
编写 SchedulingConfigurer 后,并没有执行。原因是没有在 Application 上添加如下注解:@EnableScheduling@EnableScheduling@SpringBootApplicationpublic class SbdApplication { public static void main(String[] args) { SpringApplication.run(SbdApplication.class, a.原创 2021-08-10 15:01:26 · 926 阅读 · 0 评论 -
There is already ‘xxxController‘ bean method
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'documentationPluginsBootstrapper' defined in URLxxxxxxxx nested exception is java.lang.IllegalStateException: Ambiguous mapping. Cannot map 'xxxxController' me原创 2021-08-08 16:21:02 · 135 阅读 · 0 评论 -
JAVA 时间及时区相关 API ,JAVA 时区转换备忘
TimeZone 说明public static TimeZone getTimeZone(ZoneId zoneId);这个函数使用的参数 ZoneId 的所有值可以通过以下方式获取for (String id: TimeZone.getAvailableIDs()) { System.out.println(id); } 参看:https://bytenota.com/get-list-of-all-timezone-ids-in-java/时区转换.原创 2020-11-14 10:20:20 · 334 阅读 · 0 评论 -
HTTP HEADER 中新增字段不要携带下划线备忘
header中携带了自定义的 access_token。问题一:nginx 转发请求时,默认不转发带下划线的 header。在配置中增加underscores_in_headers on;后问题解决。问题二:使用AWS Application load balancer 时,又出现了同样的问题,header丢失。没有查到相关的解决方案。最后将下划线去掉,改为accesstoken 后恢复正常。...原创 2020-11-12 12:28:42 · 292 阅读 · 0 评论 -
转:SpringBoot--““Required request part ‘file‘ is not present““
原文:https://www.cnblogs.com/runwithraining/p/12114373.html今天做图片上传的功能,做好之后进行测试,一直提示“"Required request part 'file' is not present"”在网上找各种方式,有的说配置文件,有的说别用自带的文件解析类MultipartFileResolver都没有解决我的问题。后来仔细看发送的请求------WebKitFormBoundaryFlaeSM38XP7nFtBiContent转载 2020-10-18 20:08:52 · 395 阅读 · 0 评论 -
ubuntu 下一个简单的spring boot jar包的启用脚本
比如java 程序中有环境变量的配置,需要在启动前修改环境变量,如:#!/bin/shexport TEST_ENV=dddddddddjava -jar demo4.jar对应的java代码如下:application.propertiestest-env=${TEST_ENV:hello}java@RestController@RequestMapping("/v1/ops")public class DebugController { @Valu原创 2020-07-07 17:47:03 · 356 阅读 · 0 评论 -
getServerPort 和 getLocalPort 的测试
本地配置了 nginx 转到一个 spring boot 应用:测试内容浏览器访问 abc.comnginx 代理转发到 localhost:9999观察spring boot 应用 中getServerPort 和 getLocalPort 及 header 内容spring boot 应用 java 代码@RestController@RequestMapping("/v1/ops")public class DebugController { @G...原创 2020-07-07 17:07:57 · 637 阅读 · 0 评论 -
wget 将结果直接输出到终端
wget -q -O - http://www.baidu.com/原创 2020-01-06 11:09:48 · 1363 阅读 · 0 评论 -
OutOfMemoryError: Metaspace
项目运行时,出现OutOfMemoryError: Metaspace,通过修改JVM Metaspace 相关size 解决。具体分析待补充。原创 2019-11-14 14:24:21 · 345 阅读 · 0 评论 -
swagger-ui Unable to infer base url
遇到一个奇怪的问题:打开 swagger-ui.html 弹框提示错误:Unable to infer base url. This is common when using dynamic servlet registration or when the API is behind an API Gateway. The base url is the root of where al...原创 2019-10-25 18:12:53 · 162 阅读 · 0 评论 -
spring boot 启用 swagger ui
1 pom.xml 修改 <!-- swagger-ui --> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <vers...原创 2019-10-14 14:46:15 · 130 阅读 · 0 评论 -
【转】关于group by 两个或以上条件的分析
原文:https://uule.iteye.com/blog/1569262首先group by 的简单说明: group by 一般和聚合函数一起使用才有意义,比如 count sum avg等,使用group by的两个要素: (1) 出现在select后面的字段 要么是是聚合函数中的,要么就是group by 中的. (2) 要筛选结果 可以先使用where 再用gr...转载 2019-06-19 16:23:39 · 1723 阅读 · 0 评论 -
@Valid + @Email 示例
@PostMapping("/dada") public Object getEmail(@RequestBody @Valid AEmail aemail) { System.out.println("aemail:" + aemail.email); return "fff"; } public static clas...原创 2019-06-12 10:53:31 · 11245 阅读 · 0 评论 -
springboot 项目 jenkins 自动化集成加版本号
思路是这样的:application.properties中添加一个配置项,然后在 jenkins 编译脚本中将配置项中的版本号替换掉。application.propertiesjenkins-build-number=devjenkins 编译脚本sed -i "s/jenkins-build-number.*/jenkins-build-number=$BUILD_NUM...原创 2019-05-31 14:57:36 · 1439 阅读 · 0 评论 -
向前端返回JSON字符串的细节
假设 mysql 数据库存储两个 json 类型的字段。其中一条数据值如下:info config {"a","b"} {"c","d"} 写一个vo 类对应这个返回值:class Response {String info;JsonNode config;}在 Controller 中直接返回 Response 。这时前端拿到的数据是这样的...原创 2019-05-16 14:45:29 · 1178 阅读 · 0 评论 -
mysql 时间字段的存储与处理记录
SQL `create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,POJO private Timestamp createTime; public Timestamp getCreateTime() { return createTime; } public void s...原创 2019-05-20 15:28:05 · 647 阅读 · 0 评论 -
spring mvc test 常用方法整理
spring mvc test 常用方法整理参考https://docs.spring.io/spring/docs/current/spring-framework-reference/testing.html#spring-mvc-test-framework常见写法@RunWith(SpringRunner.class)@SpringBootTestpublic c...原创 2019-05-08 18:09:28 · 401 阅读 · 0 评论 -
spring mvc 输入输出示例
之前写了一篇《spring mvc 输入输出的一些细节》https://blog.csdn.net/wuzhong8809/article/details/88327369,内容比较冗余。重新整理成表格,记录如下:输入 注解 @RequestParam + @PostMapping 说明 获取POST请求中的...原创 2019-05-08 16:05:20 · 215 阅读 · 0 评论 -
把几个类从一个包下移到了另一个包下,在本地运行OK,但打包到WAR包后上传服务器运行报错
把几个类从一个包下移到了另一个包下,在本地运行OK。打包到WAR包后上传服务器运行报错,提示无法将com.xxx.xx识别为com.aaa.aaa。解决方法:把本地的代码下的 target 目录删除,重新打包war包后,问题解决。...原创 2019-10-10 11:28:47 · 154 阅读 · 0 评论 -
【转】web工程找不到javax.servlet.http.httpservlet
https://www.cnblogs.com/qinjf/p/8206878.html转载 2019-04-18 10:08:14 · 296 阅读 · 0 评论 -
spring / spring boot / spring mvc 的区别
Springhttps://spring.io/projects/spring-frameworkThe Spring Framework provides a comprehensive programming and configuration model for modern Java-based enterprise applications - on any kind of d...原创 2019-08-11 16:00:22 · 104 阅读 · 0 评论 -
tomcat JVM卡死调试方法记录
ps -ef | grep tomcat 找到进程的PIDjstack -l pid 查看堆栈信息原创 2018-10-26 15:16:41 · 456 阅读 · 0 评论 -
tail 命令查看tomcat的日志
tail -f logs/catalina.out原创 2019-10-08 16:18:48 · 472 阅读 · 0 评论 -
javax.management.InstanceAlreadyExistsException:com.zaxxer.hikari:name=mallDataSource
两个SpringBoot应用部署在一个Tomcat中,单独部署都是正常的,一起部署,后面起动的应用就会报InstanceAlreadyExistsException,启动失败。解决方法(已验证):https://blog.csdn.net/MrLi_IT/article/details/83274089(未验证)https://www.iteye.com/bl...原创 2019-09-29 13:55:00 · 1538 阅读 · 0 评论 -
IDEA Springboot 项目打包WAR包
第一步:修改 pom.xml增加红色部分:<packaging>war</packaging><dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</art...原创 2019-08-21 20:45:44 · 135 阅读 · 0 评论 -
【转】Maven pom.xml 文件中第一行报错,problems中提示 Unknown Maven Configuration Problem
问题:Maven pom.xml 文件中第一行报错,problems中提示 Unknown Maven Configuration Problem起因:eclipse使用springboot插件生成maven项目时出现问题原因:使用springboot插件生成项目时使用的springboot版本太高为2.1.5.RELEASE解决:将2.1.5.RELEASE改成2.1.4.RELEA...转载 2019-08-20 20:21:08 · 546 阅读 · 0 评论 -
【转】PROPAGATION_REQUIRES_NEW 和 PROPAGATION_NESTED 的区别
原文:https://docs.spring.io/spring/docs/3.0.x/spring-framework-reference/html/transaction.html#tx-propagation10.5.7Transaction propagationThis section describes some semantics of transaction pro...转载 2019-04-02 14:09:55 · 260 阅读 · 0 评论 -
【转】透彻的掌握 Spring 中@transactional 的使用
原文:https://www.ibm.com/developerworks/cn/java/j-master-spring-transactional-use/转载 2019-04-10 16:59:10 · 166 阅读 · 0 评论 -
对返回前端的数据进行排序
如果排序关键字字段在数据库中有,直接让数据库返回排序好的值,比如:SQL 里的 sort by xxx ASC / DESC或 JPA的List<UserPermission> findAll(Sort sort);final List<UserPermission> upList = userPermissionRepository.findAll(new...原创 2018-11-30 17:41:10 · 4069 阅读 · 0 评论 -
MockMvc 单元测试添加 filter 记录
mMockMvc = MockMvcBuilders.webAppContextSetup(context) .addFilter(new UserFilter()) .build();原创 2018-11-30 11:46:04 · 3967 阅读 · 1 评论 -
servlet 获取客户端的IP
request.getRemoteAddr();获取客户端的IP原创 2018-11-26 15:29:14 · 414 阅读 · 0 评论 -
springmvc中controller/service返回json格式的字符串给前端的两种方法
给前端返回json格式字符串,有两种方式:一,让springmvc框架帮你自动转。框架使用jackson帮你自动转,例如:List<Apple> getAppleList() { List<Apple> appleList = repository.queryAppleList(); return appleList;}二,自行编码将...原创 2018-11-29 09:19:25 · 3439 阅读 · 0 评论 -
@RequestParam 和 @RequestBody 的区别
@RequestParamAnnotation which indicates that a method parameter should be bound to a web request parameter.HTTP请求参数比如http://xx.com/image/detail?id=5可以通过以下方式拿到参数值public getImageDetailByID(@...原创 2018-11-13 14:56:44 · 129 阅读 · 0 评论 -
启动tomcat 报错 Unsupported major.minor version 52.0 的解决方法
我本地的JDK版本为1.8。云服务器上JDK为1.7。当我把本地的WAR包,放到云端服务器tomcat/webapps/ 目录下后,启动 tomcat 报错如本文标题。想到的解决方法有三种:一 尝试用JDK1.7去编译WAR包。二 尝试云服务器升级为 JDK 1.8。三 使用 DOCKER。先尝试了[方案一],没有成功。再尝试[方案三],成功了。[方案二] 也在CS...原创 2018-11-01 10:43:39 · 1349 阅读 · 0 评论 -
查看端口使用的进程
查看8080端口,则可以结合grep命令: netstat -ap | grep 8080或lsof -i:8888 杀进程的话, kill pid原创 2018-10-30 15:49:37 · 283 阅读 · 0 评论 -
zookeeper 启动失败
./zkServer.sh startZooKeeper JMX enabled by defaultUsing config: /home/xx/data260/zookeeper/zookeeper-3.4.12/bin/../conf/zoo.cfgStarting zookeeper ... STARTED ./zkServer.sh statusZooKeeper JMX...原创 2018-10-24 11:38:54 · 804 阅读 · 3 评论 -
cross-origin request blocked / ajax 返回的HTTP状态码 status 为0
cross-origin request blocked / ajax 返回的HTTP状态码 status 为0 调试的时候可以这样处理:@RequestMapping("/img")@RestControllerpublic class ImgController { @GetMapping public Object getImgList(HttpServ...原创 2018-10-29 14:16:50 · 2347 阅读 · 0 评论 -
springboot修改启动端口号
resources中application.properties文件,里面加入server.port = 端口号原创 2018-10-29 10:46:47 · 1107 阅读 · 0 评论