草庐IT

spring - 在 Spring Boot 中为自定义 Controller 方法启用 HAL 序列化

我正在尝试使用spring-boot-starter-data-rest使用SpringBoot构建一个RESTfulAPI。有一些实体:帐户、交易、类别和用户-只是普通的东西。当我在http://localhost:8080/transactions检索对象时通过默认生成的API,一切顺利,我得到了一个列表,其中包含所有事务作为JSON对象,如下所示:{"amount":-4.81,"date":"2014-06-17T21:18:00.000+0000","description":"Pizza","_links":{"self":{"href":"http://localhost

java - Spring boot在webapp文件夹下找不到index.html

我从spring.io阅读了以下文档它说默认情况下SpringBoot将提供来自类路径中名为/static(或/public或/resources或/META-INF/resources)的目录的静态内容但是当我把我的index.html/resources下的文件中,字符串index刚刚被渲染。目前index.html在webapp下,我正在使用AngularJS。Mvc配置@ConfigurationpublicclassMvcConfig{@BeanInternalResourceViewResolverviewResolver(){InternalResourceViewRes

java - 如何在 Spring Boot 中注册自定义转换器?

我使用spring-boot-starter-jdbc(v1.3.0)编写应用程序。我遇到的问题:BeanPropertyRowMapper的实例失败,因为它无法从java.sql.Timestamp转换为java.time.LocalDateTime.为了复制这个问题,我实现了org.springframework.core.convert.converter.Converter用于这些类型。publicclassTimeStampToLocalDateTimeConverterimplementsConverter{@OverridepublicLocalDateTimeconve

spring - 如何在代理后面设置 Spring Boot CLI

我目前正在尝试在我的公司代理后面利用SpringBootCLI。我尝试了很多不同的方法来为SpringBootCLI设置代理,但都没有成功。我试过设置:1)代理的JAVA_OPTS环境变量-Dhttp.proxyHost=proxyhostURL-Dhttp.proxyPort=proxyPortNumber-Dhttp.proxyUser=someUserName-Dhttp.proxyPassword=somePassword2)我尝试只配置http代理环境变量http_proxy我之前发现过几年前关闭的githubbug,但似乎不相关:https://github.com/spr

带有 jwt 授权的 Spring Boot 4.3.5 WebSocket 聊天。 GenericMessage 中没有目的地

我正在尝试为带有springboot后端的移动应用程序(ionic3)实现1-1聊天。似乎遇到了一些配置问题。无法发送消息可能是因为没有创建目标channel后端:聊天Controller:@RestControllerpublicclassChatController{@AutowiredprivatePrivateChatServiceprivateChatService;privatefinalstaticLoggerlogger=LogManager.getLogger(ChatController.class.getName());@RequestMapping(value=

spring - 性能 - Spring Boot - 服务器响应时间

我的SpringBoot应用程序出现了一个奇怪的行为:前端/客户端-角度6后端-springboot-springMVC-嵌入式tomcat-Linux重启后端后,对Controller的第一次调用大约需要5秒,以下相同的请求只需要50毫秒。这在90%的情况下是可重现的,有时甚至第一次调用也很快。我确定,问题出在服务器上而不是客户端上。在浏览器上,我看到TTFB时间(到第一个字节的时间)增加到5秒。以下请求只需要10ms的TTFB。使用服务器上的监控工具(应用程序动态),我可以收集如此缓慢的服务器调用,并且在调用图上我可以看到:org.apache.catalina.webresour

Spring Boot/Spring Security AuthenticationEntryPoint 未执行

我创建了一个包含此方法的类JwtAuthenticationFilter:@OverridepublicAuthenticationattemptAuthentication(HttpServletRequestrequest,HttpServletResponseresponse)throwsAuthenticationException{Authenticationauthentication=null;if(hasJsonToken(request)){JwtAuthenticationTokenjwtAuthenticationToken=newJwtAuthenticatio

java - 在 Spring Boot 应用程序的多个数据库中未创建表

我正在开发SpringBootMulti-Tenancy应用程序。我已经配置了多个数据源,如下所示:application.propertiesspring.multitenancy.datasource1.url=jdbc:mysql://localhost:3306/db1spring.multitenancy.datasource1.username=rootspring.multitenancy.datasource1.password=****spring.multitenancy.datasource1.driver-class-name=com.mysql.jdbc.Dr

Spring Boot 2 和 OAuth2/JWT 配置

我正在尝试将我的SpringBoot1.5应用程序移植到SpringBoot2现在我无法获取OAuth2访问token。这是我在SpringBoot1.5中成功使用的代码:publicstaticStringloginAndGetAccessToken(Stringusername,Stringpassword,intport){ResourceOwnerPasswordResourceDetailsresourceDetails=newResourceOwnerPasswordResourceDetails();resourceDetails.setUsername(username

java - 在 Spring Boot 应用程序中超时后如何以与 weblogic 相同的方式回滚事务

所以在我的weblogic应用程序中,我们正在使用一些jtaWeblogicTransactionManager。有一些默认超时可以在注释@Transactional(timeout=60)中被覆盖。我创建了一些无限循环来从正确超时的db读取数据:29Apr201820:44:55,458WARN[[ACTIVE]ExecuteThread:'9'forqueue:'weblogic.kernel.Default(self-tuning)']org.springframework.jdbc.support.SQLErrorCodesFactory:Errorwhileextractin