草庐IT

java - 使用 JUnit 5 的 spring-boot-starter-test

从2.0.6开始使用spring-boot-starter-test会引入JUnit4依赖项。如何使用spring-boot-starter-test(通过Gradle),但使用JUnit5,而不引入JUnit4依赖项?如果有帮助,这里是Gradle的依赖输出的一部分:+---org.springframework.boot:spring-boot-starter-test->2.0.5.RELEASE|+---org.springframework.boot:spring-boot-starter:2.0.5.RELEASE(*)|+---org.springframework.bo

java - 创建自定义 RestTemplate 时 Spring-boot 出错

我有一个sendGetREST方法来发送一些URL端点并获得响应:@ComponentpublicclassHttpURLCommand{privatestaticLoggerlogger=Logger.getLogger(HttpURLCommand.class);publicStringsendGetREST(StringsoapUrl,Object[]parameters)throwsIOException{finalStringSOAP_URL=MessageFormat.format(soapUrl,parameters);RestTemplaterestTemplate=n

java - 变量的 Spring Boot 约定

所以我有一个application.yml文件用于我的SpringBoot应用程序,如下所示:spring:url:localhostemail:from:something@gmail.comapp:uuid:3848348j34jk2dne9我想将这些配置属性连接到我的应用程序中的不同组件中,如下所示:@ComponentpublicclassFooA{privatefinalStringurl;publicFooA(@Value("${spring.url}")Stringurl){this.url=url}}@ComponentpublicclassFooB{privatefi

Spring Boot Actuator - LDAP Health Endpoint Throwing NPE

在我们的SpringBoot应用程序中,我们使用spring-security-ldap来验证可以访问我们应用程序的用户。我们在身份验证方面没有发现任何功能问题,但是当我们点击/authenticator/healthURL时,我们会得到ldap的以下状态:"ldap":{"status":"DOWN","error":"java.lang.NullPointerException:null"}追踪这个空指针异常,我们在尝试访问env.put(Context.SECURITY_PRINCIPAL,userDn);时得到了这个踪迹;:java.lang.NullPointerExcept

java - Spring Boot jdbc 数据源自动配置在独立 tomcat 上失败

在尝试在独立的tomcat(7)实例上部署和启动springboot应用程序时,我们遇到了一个问题,即找不到自动配置的spring数据源bean并引发了相应的异常:Causedby:org.springframework.beans.factory.NoSuchBeanDefinitionException:Noqualifyingbeanoftype[javax.sql.DataSource]foundfordependency:expectedatleast1beanwhichqualifiesasautowirecandidateforthisdependency.Depende

使用 Spring Boot 时出现 Spring 批处理范围问题

我有独立的Spring批处理作业。这在JUNIT中工作得非常好@RunWith(SpringJUnit4ClassRunner.class)//@SpringApplicationConfiguration(classes=KPBootApplication.class)@ContextConfiguration(locations={"classpath:kp-sb.xml"})publicclassKPBootApplicationTests{privatefinalstaticLoggerLOG=LoggerFactory.getLogger(KPBootApplicationT

spring - 如何在 Spring Boot 应用程序中预编译 jsp?

我使用的是Springboot,之前我们使用的是Spring和Tomcat。两年前我们使用Spring和Tomcat的时候,我们使用了一个maven插件来预编译jsp。避免在部署后的每次首次访问时都进行此编译非常有用。然而,我们所知道的所有maven插件都会转储一个web.xml文件,其中列出了所有jsp和相关的生成的servlet。使用Springboot,它不再使用web.xml,因此该文件被忽略。我们仍然有汇编,这是一条安全带,但每次首次访问每个页面都会受到处罚。有人知道是否可以在SpringBoot应用程序中预编译jsp吗? 最佳答案

java - Spring-Boot:如何在 @ImportResource 中引用 application.properties

我的SpringBoot应用程序中有一个applicationContext.xml文件。在这个文件中,它有一个属性占位符-${profile.services.url}-用于配置bean的“地址”属性。在我的Application.java类中,我导入了这个文件。@ImportResource("classpath:applicationContext.xml")publicclassApplication{publicstaticvoidmain(String[]args){SpringApplication.run(Application.class,args);}}我在appl

java - 为什么添加 @EnableAutoConfiguration 会导致 spring-boot 失败并显示 "Unable to find JPA packages to scan"

为什么将@EnableAutoConfiguration添加到以下spring-boot应用程序会导致它无法创建entityManagerFactory?如果我删除@EnableAutoConfiguration一切正常。任何人都可以阐明这种行为吗?packagetest.builder;importjavax.sql.DataSource;importorg.slf4j.Logger;importorg.slf4j.LoggerFactory;importorg.springframework.beans.factory.annotation.Value;importorg.spri

java - spring boot 启动后停止

错误是:/usr/lib/jvm/java-8-oracle/bin/java-agentlib:jdwp=transport=dt_socket,address=127.0.0.1:40745,suspend=y,server=n-Dspring.output.ansi.enabled=always-Dfile.encoding=UTF-8-classpath/usr/lib/jvm/java-8-oracle/jre/lib/charsets.jar:/usr/lib/jvm/java-8-oracle/jre/lib/deploy.jar:/usr/lib/jvm/java-8-