Questions tagged «spring-boot»

Spring Boot是一个框架,可让您轻松创建以Spring为动力的生产级应用程序和服务,而无需大惊小怪。它对旨在供Spring的新老用户使用的Spring平台持保留态度。

4
如何在gradle引导测试中关闭关闭钩子的输出?
您可以从https://start.spring.io/starter.zip?type=gradle-project&language=java&bootVersion=2.2.5.RELEASE&baseDir=demo&groupId=com.example&artifactId=demo&name生成从start.spring.io到此问题的项目= demo&d​​escription = Demo%20project%20for%20Spring%20Boot&packageName = com.example.demo&packaging = jar&javaVersion = 1.8&dependencies = h2,data-jpa,web 我有一个用gradle构建的多模块springBoot应用程序,其中有很多SpringBoot集成测试。当我进行构建时,最终会从SpringBoot关闭到控制台获得一些输出,如下所示。如何关闭此输出? ± |master ↑1 {1} S:3 U:10 ✗| → ./gradlew build > Task :core:test 2020-02-01 11:20:33.529 INFO 24114 --- [extShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default' 2020-02-01 11:20:33.531 INFO 24114 --- [extShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 …

5
Springfox swagger在Spring Boot 2.2.0中不起作用
我想将Spring Boot v2.1.9升级到2.2.0。但是升级之后,我得到了一些例外,这表示Spring Fox使用的是Spring-plugin-core的旧版本。 是否有其他替代解决方案,还是我需要放弃springfox插件? *************************** APPLICATION FAILED TO START *************************** Description: An attempt was made to call a method that does not exist. The attempt was made from the following location: springfox.documentation.spring.web.plugins.DocumentationPluginsManager.createContextBuilder(DocumentationPluginsManager.java:152) The following method did not exist: org.springframework.plugin.core.PluginRegistry.getPluginFor(Ljava/lang/Object;Lorg/springframework/plugin/core/Plugin;)Lorg/springframework/plugin/core/Plugin; The method's class, org.springframework.plugin.core.PluginRegistry, is available from the following locations: …

1
Spring Security中已弃用的AuthorizationServer的替代品是什么?
Spring Security 5.2.2已合并了Spring Security OAuth项目,但未合并AuthorizationServer或ResourceServer。Spring Security 5.2.2中什么是AuthorizationServer的替代品? OAuth-2.0迁移指南 本文档包含有关将OAuth 2.0客户端和资源服务器从Spring Security OAuth 2.x迁移到Spring Security 5.2.x的指南。由于Spring Security不提供Authorization Server支持,因此迁移Spring Security OAuth Authorization Server超出了本文档的范围。

10
Spring Boot 2.2.0 Spring HateOas启动问题
我将项目从Spring Boot 2.1.9迁移到了2.2.0。在启动项目时,面临以下error消息。 可能造成的原因,也不hateoas在我的pom.xml文件中使用。 Caused by: org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'org.springframework.plugin.core.PluginRegistry<org.springframework.hateoas.client.LinkDiscoverer, org.springframework.http.MediaType>' available: expected single matching bean but found 17: modelBuilderPluginRegistry,modelPropertyBuilderPluginRegistry,typeNameProviderPluginRegistry,syntheticModelProviderPluginRegistry,documentationPluginRegistry,apiListingBuilderPluginRegistry,operationBuilderPluginRegistry,parameterBuilderPluginRegistry,expandedParameterBuilderPluginRegistry,resourceGroupingStrategyRegistry,operationModelsProviderPluginRegistry,defaultsProviderPluginRegistry,pathDecoratorRegistry,apiListingScannerPluginRegistry,relProviderPluginRegistry,linkDiscovererRegistry,entityLinksPluginRegistry Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'linkDiscoverers' defined in class path resource [org/springframework/hateoas/config/HateoasConfiguration.class]: Unsatisfied dependency expressed through method 'linkDiscoverers' parameter 0; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: …

3
如何在Spring Boot中启用版本为'2.0.0-alpha1'的org.slf4j登录
我已使用SLF4J日志记录来打印所有日志。我正在使用最新版本的org.slf4j。 实现'org.slf4j:slf4j-api:2.0.0-alpha1' 实现'org.slf4j:log4j-over-slf4j:2.0.0-alpha1' 但是我收到以下错误,并且也没有打印日志。 SLF4J: No SLF4J providers were found. SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#noProviders for further details. SLF4J: Class path contains SLF4J bindings targeting slf4j-api versions prior to 1.8. SLF4J: Ignoring binding found at [jar:file:/home/user/.gradle/caches/modules-2/files-2.1/ch.qos.logback/logback-classic/1.2.3/7c4f3c474fb2c041d8028740440937705ebb473a/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#ignoredBindings for an explanation. 日志在较早版本(1.7.25)上正常工作。是否需要在项目上添加或配置任何内容,以便可以打印这些日志

5
在从字符串> 4k创建的谓词中使用Oracle Clob
我正在尝试从> 4000个字符(在file_data绑定变量中提供)的字符串创建一个Clob,以在下面的Oracle SELECT谓词中使用: myQuery= select * from dcr_mols WHERE flexmatch(ctab,:file_data,'MATCH=ALL')=1; 如果我将TO_CLOB()添加到file_data的周围,则它将无法达到臭名昭著的Oracle 4k对varchar的限制(对于<4k的字符串就可以)。错误(在SQL Developer中)为: ORA-01460: unimplemented or unreasonable conversion requested 01460. 00000 - "unimplemented or unreasonable conversion requested" 仅供参考,flexmatch函数用于搜索分子,在此处进行了描述:http : //help.accelrysonline.com/ulm/onelab/1.0/content/ulm_pdfs/direct/developers/direct_2016_developersguide.pdf 函数本身有点复杂,但本质是第二个参数必须是Clob。所以我的问题是如何将超过4000个字符的Java字符串bind_variable转换为sql(或Java)中的clob。 我使用以下方法在Java(Spring boot 2)中尝试了以下方法(在插入Clob时有效): MapSqlParameterSource parameters = new MapSqlParameterSource(); parameters.addValue("file_data", fileDataStr,Types.CLOB); jdbcNamedParameterTemplate.query(myQuery,parameters,… 此方法应该可以工作,但是会失败,并会产生一个弹性匹配错误,仅供参考: SQL state [99999]; error code [29902]; ORA-29902: …

1
使用Spring Boot 2和Spring Security 5进行多重身份验证
我想在Angular&Spring应用程序中添加具有TOTP软令牌的多因素身份验证,同时使所有内容尽可能接近Spring Boot Security Starter的默认值。 令牌验证在本地进行(使用aerogear-otp-java库),没有第三方API提供程序。 为用户设置令牌是可行的,但无法通过利用Spring Security Authentication Manager / Providers来验证令牌。 TL; DR 将额外的AuthenticationProvider集成到Spring Boot Security Starter配置的系统中的正式方法是什么? 建议采用什么方法来防止重放攻击? 长版 该API具有一个端点/auth/token,前端可以通过提供用户名和密码从该端点获取JWT令牌。该响应还包括一个身份验证状态,可以为AUTHENTICATED或PRE_AUTHENTICATED_MFA_REQUIRED。 如果用户需要MFA,则使用授予的单个授权PRE_AUTHENTICATED_MFA_REQUIRED和5分钟的到期时间来颁发令牌。这使用户可以访问端点/auth/mfa-token,在端点上可以从其Authenticator应用程序提供TOTP代码,并获取经过完全身份验证的令牌来访问站点。 提供者和令牌 我创建了MfaAuthenticationProvider实现AuthenticationProvider以下内容的自定义: @Override public Authentication authenticate(Authentication authentication) throws AuthenticationException { // validate the OTP code } @Override public boolean supports(Class<?> authentication) { return OneTimePasswordAuthenticationToken.class.isAssignableFrom(authentication); } 还有一个OneTimePasswordAuthenticationToken扩展AbstractAuthenticationToken名,用于保存用户名(取自签名的JWT)和OTP代码。 设定档 我有我的自定义WebSecurityConfigurerAdapter,我AuthenticationProvider通过添加我的自定义http.authenticationProvider()。根据JavaDoc,这似乎是正确的位置: 允许添加一个额外的AuthenticationProvider来使用 …

2
有任何Springfox替代品吗?
最近两年,我与Springfox合作开发了Spring Boot应用程序。Springfox为您的REST API生成文档和测试ui。太棒了 但是实际上Springfox项目已经死了,并且不支持最新的Spring。我有三个问题 还有其他直接生成Swagger UI的方法吗?还有其他图书馆/项目吗? 如何在Spring Boot项目中实现swagger ui? 也许已经过时了,对于Spring Boot来说,有没有更好的选择? 更新 经过数月的大量使用和测试 SpringDoc OpenApi 我会说这不是springfox的替代品,它要好得多!稳定,易于使用且最新! 我可以100%推荐这个!我们将所有项目迁移到SpringDoc OpenApi。


3
Spring Boot 2嵌入tomcat 9.0.26无法加载jks文件流关闭
我尝试在嵌入了tomcat 9.0.26的Spring Boot 2.2.0上使用SSL,但是tomcat无法关闭JKS文件流。 这是应用程序属性: server.port=443 server.ssl.key-store-type=JKS server.ssl.key-store=C:\\Keystore\\mykey.jks server.ssl.key-store-password=cccc server.ssl.key-alias=*.mydomain.com 例外: org.springframework.boot.web.server.WebServerException:无法在org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:215)〜[spring-boot-2.2.0上启动嵌入式Tomcat服务器。 ..BUILD-SNAPSHOT.jar!/:2.2.0.BUILD-SNAPSHOT]位于org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.startWebServer(ServletWebServerApplicationContext.java:297)〜[spring-boot-2.2.0。 BUILD-SNAPSHOT.jar!/:2.2.0.BUILD-SNAPSHOT],位于org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:163)〜[spring-boot-2.2.0.BUILD -SNAPSHOT.jar!/:2.2.0.BUILD-SNAPSHOT]位于org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:553)〜[spring-context-5.2.0.RELEASE。jar!/:5.2.0.RELEASE]位于org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)〜[spring-boot-2.2.0.BUILD-SNAPSHOT.jar!/ :2.2.0.BUILD-SNAPSHOT]在org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747)〜[spring-boot-2.2.0.BUILD-SNAPSHOT.jar!/:2.2.0.BUILD- SNAPSHOT],网址为org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)〜[spring-boot-2.2.0.BUILD-SNAPSHOT.jar!/:2.2.0.BUILD-SNAPSHOT]。 boot.SpringApplication.run(SpringApplication.java:315)〜[spring-boot-2.2.0.BUILD-SNAPSHOT.jar!/:2.2.0.BUILD-SNAPSHOT]在org.springframework.boot.SpringApplication.run(SpringApplication .java:1226)〜[spring-boot-2.2.0.BUILD-SNAPSHOT.jar!/:2.2.0。BUILD-SNAPSHOT],位于欧盟org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)〜[spring-boot-2.2.0.BUILD-SNAPSHOT.jar!/:2.2.0.BUILD-SNAPSHOT]。 soluma.app.SolumaTdvApplication.main(SolumaTdvApplication.java:34)〜[classes!/:0.0.1-SNAPSHOT] at java.base / jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(本机方法)〜[na:na]在java.base / jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)〜[na:na]在java.base / jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)〜 na:na]在java.base / java.lang.reflect.Method.invoke(Method.java:567)〜[na:na]在org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) 〜[SolumaTDV-0.0.1-SNAPSHOT.jar:0.0。org.springframework.boot.loader.Launcher.launch(Launcher.java:87)的[1-SNAPSHOT]〜org.springframework.boot.loader中的[SolumaTDV-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]。 Launcher.launch(Launcher.java:51)〜[SolumaTDV-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]在org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52)〜[SolumaTDV -0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]由以下原因引起:java.lang.IllegalArgumentException:standardService.connector.startFailed at org.apache.catalina.core.StandardService.addConnector(StandardService.java:231)〜[ tomcat-embed-core-9.0.26.jar!/:9.0.26],位于org.springframework.boot.web.embedded.tomcat.TomcatWebServer.addPreviouslyRemovedConnectors(TomcatWebServer.java:278)〜[spring-boot-2.2.0 ..BUILD-SNAPSHOT.jar!/:2.2.0.BUILD-SNAPSHOT]位于org.springframework.boot。web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:197)〜[spring-boot-2.2.0.BUILD-SNAPSHOT.jar!/:2.2.0.BUILD-SNAPSHOT] ...省略了18个常见框架创建人:org.apache.catalina.LifecycleException:协议处理程序启动失败,发生在org.apache.catalina.connector.Connector.startInternal(Connector.java:1008)〜[tomcat-embed-core-9.0.26.jar!/:9.0 .26]在org.apache.catalina.core上的org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)〜[tomcat-embed-core-9.0.26.jar!/:9.0.26] .StandardService.addConnector(StandardService.java:227)〜[tomcat-embed-core-9.0.26.jar!/:9.0.26] ...省略了20个常见框架导致原因:java.lang.IllegalArgumentException:流在以下位置关闭org.apache.tomcat.util.net.AbstractJsseEndpoint.createSSLContext(AbstractJsseEndpoint.java:99)〜[tomcat-embed-core-9.0.26.jar!/:9.0.26]在org.apache.tomcat.util.net.AbstractJsseEndpoint.initialiseSsl(AbstractJsseEndpoint.java:71)〜[tomcat-embed-core -9.0.26.jar!/:9.0.26]在org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:218)〜[tomcat-embed-core-9.0.26.jar!/: 9.0.26],位于org.apache.tomcat.util.net.AbstractEndpoint.bindWithCleanup(AbstractEndpoint.java:1124)〜[tomcat-embed-core-9.0.26.jar!/:9.0.26],位于org.apache。 tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:1210)〜[tomcat-embed-core-9.0.26.jar!/:9.0.26]在org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java :585)〜[tomcat-embed-core-9.0.26.jar!/:9.0.26]在org.apache.catalina.connector.Connector.startInternal(Connector.java:1005)〜[tomcat-embed-core- 9.0.26.jar!/:9.0。[26] ... ...省略了22个共同的框架导致原因:java.io.IOException:流在java.base / …

5
基本的Spring Boot应用程序无法正常工作,显示:无法刷新来自进程xxxx的实时数据
我是春季靴的初学者。我初始化了一个新项目并尝试运行它,但是它无法成功运行。当我将其作为spring boot应用程序运行时,它开始执行。在底部的编译器/状态栏中,它显示处理和重试。它最多上升10次并引发以下错误: 无法刷新来自进程xxxx的实时数据 在这里更多细节 TanmayTestApplication.java package com.example.tanmay_test; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class TanmayTestApplication { public static void main(String[] args) { SpringApplication.run(TanmayTestApplication.class, args); } } DemoControler.java package com.example.cntr; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RequestMapping; @RestController public class DemoControler { @RequestMapping(path = "/index") public String index() { return "By Tanmay!"; } } …


2
java.net.SocketException:Spring Rest模板中的连接重置
我这里有一个奇怪的问题。 在我重新启动客户端的tomcat服务器之前,以下代码可以正常工作。一旦我使用相同代码的最新war文件重启tomcat服务器(war文件中存在客户端程序),它将引发以下错误。我正在使用JDK 8。 下面是示例代码。从浏览器中,我可以从以下程序中使用的URL获得响应。但也无法使用Java程序或Postman获取数据。 package com.example.demo; import org.springframework.boot.CommandLineRunner; import org.springframework.stereotype.Component; import org.springframework.web.client.RestTemplate; @Component public class TestService implements CommandLineRunner{ @Override public void run(String... args) throws Exception { download(); } private void download() { System.out.println("Started download"); try{ RestTemplate restTemplate = new RestTemplate(); String url = "https://www.nseindia.com/live_market/dynaContent/live_watch/stock_watch/niftyStockWatch.json"; byte[] forObject = restTemplate.getForObject(url, byte [].class); …

1
不能在Docker上运行JavaFX应用超过几分钟
我开发了一个用作单独Web应用程序的通信服务的应用程序。我有0个问题“正在使Web应用程序码头化”,但事实证明该服务是一场噩梦。它基于JavaFX,并且可以由用户在配置文件中设置一个属性,该属性使该属性不会使应用程序初始化任何窗口,菜单,容器等。这种“无头”模式(不确定是否真正无头...)有效地将服务应用程序变为后台服务。让我也以此开头作为开头,说该应用程序在Windows 10机器上运行时绝对可以完美运行,并且我已经将其部署在其他几台机器(所有未经过dockerized)上,没有任何问题。 这是我想出的dockerfile: FROM openjdk:13.0.1-slim RUN apt-get update && apt-get install libgtk-3-0 libglu1-mesa -y && apt-get update VOLUME /tmp ADD Some_Service-0.0.1-SNAPSHOT.jar Some_Service-0.0.1-SNAPSHOT.jar ADD lib lib ADD config.properties config.properties ENTRYPOINT ["java", "--module-path", "lib/javafx-sdk-13", "-jar", "Some_Service-0.0.1-SNAPSHOT.jar"] 然后,我使用此命令来构建容器: docker run -t --name Some_Service -e DISPLAY=192.168.1.71:0.0 -e SERVICE_HOME= --link mySQLMD:mysql some_service 假设VcXsrv在我的PC上运行,则该应用程序可以正确启动,尽管在首次启动时确实会给出以下警告: libGL error: …

3
Oracle JDBC优化:在Spring Boot应用程序中启用PreparedStatement缓存
我有一个连接到Oracle数据库的Spring Boot REST应用程序。我们正在通过JdbcTemplate使用JDBC。Oracle数据库属性是通过以下3个application.properties设置获得的: spring.datasource.url spring.datasource.username spring.datasource.password 该应用程序正在使用HikariCP。从HikariCP网站上,我知道该池不缓存PreparedStatements,因为JDBC驱动程序是最好的设置。 现在,我将在哪里指定什么来确保这些: Oracle JDBC驱动程序(ojdbc7.jar)缓存PreparedStatements。有没有一种方法可以自定义它可以缓存的PreparedStatements的数量。 从https://howtodoinjava.com/java/jdbc/best-practices-to-improve-jdbc-performance/中,我们看到 确保将数据库设置为最大数据包大小,并且驱动程序与该数据包大小匹配。为了获取更大的结果集,这减少了驱动程序和服务器之间发送/接收的总数据包数量。 为此,需要采取哪些步骤? 查找Oracle DB Server数据包大小 查找是否将Oracle DB Server设置为最大数据包大小 查找设置Oracle JDBC驱动程序的(ojdbc8.jar)数据包大小。 任何其他(Oracle)JDBC性能优化技巧将不胜感激。
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.