小编Bri*_*zel的帖子

VMware vFabric tc Server Developer需要端口8080

我正在使用VMware vFabric tc Server Developer Edition v2.6附带的STS(SpringSource Tool Suite).问题是,每次启动它时,都会显示以下错误:

VMware vFabric tc Server Developer Edition v2.6所需的端口8080已在使用中.服务器可能已在另一个进程中运行,或者系统进程可能正在使用该端口.要启动此服务器,您需要停止其他进程或更改端口号.

我没有使用我所知道的那个端口.它一直很好,直到今天.

我也尝试更改端口号,但它不接受更改.例如,如果我将其更改为8081,然后重新启动STS,则会覆盖端口并将其重置为8080.

谁能提供一些想法来解决这个问题?

仅供我在VirtualBox中运行STS.

谢谢!

vmware sts-springsourcetoolsuite tcserver

8
推荐指数
3
解决办法
1万
查看次数

A/B,使用spring MVC进行多变量测试

我想在现有的电子商务网站上开始A/B测试和/或多变量测试体验.这个网站严重依赖于vanilla Spring + Spring MVC.

许多分析产品(如Google内容实验)处理统计信息收集+变体选择; 你基本上必须为每个变体创建一个URL(并在GCE中配置每个URL).

人们可以使用:

这些技术是否符合这个用例?

您是否有使用Spring MVC进行A/B测试或多变量测试的经验?

或许您认为这些功能应该由特定的JavaScript框架处理,例如同类群组

spring-mvc ab-testing

8
推荐指数
1
解决办法
1407
查看次数

如何使反应式webclient遵循3XX重定向?

我创建了一个基本的REST控制器,它使用netty在Spring-boot 2中使用被动Webclient进行请求.

@RestController
@RequestMapping("/test")
@Log4j2
public class TestController {

    private WebClient client;

    @PostConstruct
    public void setup() {

        client = WebClient.builder()
                .baseUrl("http://www.google.com/")
                .exchangeStrategies(ExchangeStrategies.withDefaults())
                .build();
    }


    @GetMapping
    public Mono<String> hello() throws URISyntaxException {
        return client.get().retrieve().bodyToMono(String.class);
    }

}
Run Code Online (Sandbox Code Playgroud)

当我收到3XX响应代码时,我希望webclient使用响应中的Location来跟踪重定向,并递归调用该URI,直到我得到非3XX响应.

我得到的实际结果是3XX响应.

spring-boot project-reactor reactor-netty spring-webflux

8
推荐指数
2
解决办法
2517
查看次数

Spring 5 - 如何提供静态资源

我正在尝试在我的Web应用程序中提供静态资源,我试过:

@SuppressWarnings("deprecation")
@Bean
WebMvcConfigurerAdapter configurer(){
    return new WebMvcConfigurerAdapter() {
        @Override
        public void addResourceHandlers (ResourceHandlerRegistry registry) {
            registry.addResourceHandler("/**").
                      addResourceLocations("classpath:/static/");
        }
    };
}
Run Code Online (Sandbox Code Playgroud)

但是在Spring 5中不推荐使用WebMvcConfigurerAdapter.如何立即访问静态资源?

java resources spring spring-mvc spring-webflux

7
推荐指数
1
解决办法
9980
查看次数

为什么在将其部署到外部tomcat时需要扩展`SpringBootServletInitializer`

我们为什么要扩展SpringBootServletInitializer以便将SpringBoot应用程序运行到外部tomcat

如果没有扩展SpringBootServletInitializer它在嵌入式tomcat上运行那么为什么有必要SpringBootServletInitializer在将它部署到外部tomcat 时进行扩展?

java deployment tomcat spring-boot

7
推荐指数
2
解决办法
3099
查看次数

Spring WebFlux - ServerResponse Jackson Serializer问题

在向我的Web服务器发送HTTP GET请求时遇到问题.以下是负责此资源的代码片段:

@GetMapping("/events")
public Mono<ServerResponse> getEvents() {
    return ServerResponse.ok()
              .contentType(APPLICATION_JSON)
              .build();
}
Run Code Online (Sandbox Code Playgroud)

发送请求时,我收到异常:

org.springframework.core.codec.CodecException: Type definition error: [simple type, class org.springframework.web.reactive.function.server.DefaultServerResponseBuilder$WriterFunctionServerResponse]; nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class org.springframework.web.reactive.function.server.DefaultServerResponseBuilder$WriterFunctionServerResponse and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS)
at org.springframework.http.codec.json.AbstractJackson2Encoder.encodeValue(AbstractJackson2Encoder.java:162) ~[spring-web-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.http.codec.json.AbstractJackson2Encoder.lambda$encode$0(AbstractJackson2Encoder.java:119) ~[spring-web-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:107) [reactor-core-3.1.6.RELEASE.jar:3.1.6.RELEASE]
at reactor.core.publisher.FluxJust$WeakScalarSubscription.request(FluxJust.java:91) [reactor-core-3.1.6.RELEASE.jar:3.1.6.RELEASE]
at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.request(FluxMapFuseable.java:156) [reactor-core-3.1.6.RELEASE.jar:3.1.6.RELEASE]
at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.set(Operators.java:1444) [reactor-core-3.1.6.RELEASE.jar:3.1.6.RELEASE]
at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.onSubscribe(Operators.java:1318) [reactor-core-3.1.6.RELEASE.jar:3.1.6.RELEASE]
at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onSubscribe(FluxMapFuseable.java:90) [reactor-core-3.1.6.RELEASE.jar:3.1.6.RELEASE]
at reactor.core.publisher.FluxJust.subscribe(FluxJust.java:68) [reactor-core-3.1.6.RELEASE.jar:3.1.6.RELEASE]
at reactor.core.publisher.FluxMapFuseable.subscribe(FluxMapFuseable.java:63) [reactor-core-3.1.6.RELEASE.jar:3.1.6.RELEASE]
at reactor.core.publisher.Flux.subscribe(Flux.java:6873) ~[reactor-core-3.1.6.RELEASE.jar:3.1.6.RELEASE]
at reactor.core.publisher.FluxConcatArray$ConcatArraySubscriber.onComplete(FluxConcatArray.java:200) ~[reactor-core-3.1.6.RELEASE.jar:3.1.6.RELEASE]
at …
Run Code Online (Sandbox Code Playgroud)

java spring jackson spring-boot spring-webflux

7
推荐指数
1
解决办法
3794
查看次数

Spring Boot 3.0 + Security 6 +WebFlux 导致 Postman 中“找不到预期的 CSRF 令牌”

以下SecurityWebFilterChain在 Spring Boot 2.7.x 中工作得很好,但在 Spring Boot 3.0.0 中不再工作。在Postman中调用REST API时,它只是显示“无法找到预期的CSRF令牌”。请您教我如何解决它?

@Bean
public SecurityWebFilterChain securitygWebFilterChain(ServerHttpSecurity http) {
    
    
    http
            .cors().disable()               
            .csrf().disable()
            
            .exceptionHandling()
            .authenticationEntryPoint((swe, e) -> 
                Mono.fromRunnable(() -> swe.getResponse().setStatusCode(HttpStatus.UNAUTHORIZED))
            ).accessDeniedHandler((swe, e) -> 
                Mono.fromRunnable(() -> swe.getResponse().setStatusCode(HttpStatus.FORBIDDEN))
            )
            .and()
            .authenticationManager(authenticationManager)
            .securityContextRepository(securityContextRepository)
            .authorizeExchange(exchange -> exchange                                     
                    .pathMatchers(HttpMethod.OPTIONS).permitAll()
                    .pathMatchers("/login", "/register").permitAll()                        
                    .anyExchange().authenticated()
                    .and()
                    .cors().disable()
                    .csrf().disable()
            )
            .formLogin().disable()
            .httpBasic().disable()   
            ;
            
    return http.csrf(csrf -> csrf.disable()).build();
}
Run Code Online (Sandbox Code Playgroud)

邮递员屏幕截图

csrf spring-security spring-boot

7
推荐指数
2
解决办法
6146
查看次数

在 Spock 中进行测试的 Spring Boot 3 不会在 @SpringBootTest 测试中创建上下文

我使用最新的 Spring Boot 3 和 spock 版本创建了简单的项目,您可以在这里找到: https: //github.com/RafBorkowski/SpringBoot3SpockExample。当我尝试使用 junit 启动测试时,spring 的上下文正常启动并测试通过,但是当我尝试在 spock 中进行相同的测试时,我注意到 spring 没有启动并且没有创建上下文,这导致了测试失败。当我将 Spring boot 版本降级到 2.7.5 时,一切正常。

PS 我在 github 上的 README 中添加了屏幕截图和响应。

有任何想法吗?

java integration-testing spock spring-boot

7
推荐指数
1
解决办法
2855
查看次数

Instant as timestamp fails with Spring Boot 3 in combination with PostgreSQL

Spring Boot 3 (Hibernate 6.1) in combination with PostgreSQL seems to have a problem with Instant values mapped to SQL timestamps (without time zone), as the following test case fails. Values read differ from the written values by the amount of the local time zone offset.

The test case executes successfully when using the H2 test database or when switching back to Spring Boot 2.7.6 (Hibernate 5.6).

JPA entity:

@Entity
public class MyEntity {

  @Id
  UUID id …
Run Code Online (Sandbox Code Playgroud)

java postgresql hibernate spring-boot

7
推荐指数
1
解决办法
3120
查看次数

对于不存在的JAR,"IllegalStateException:没有匹配的文件或目录"

我最近尝试将我的Gradle构建升级到SonarQube插件2.2并遇到以下错误:

Caused by: java.lang.IllegalStateException: No files nor directories matching '[/opt/bamboo-home/xml-data/build-dir/SPR-SONAR-JOB1/spring-core/build/libs/spring-cglib-repack-3.2.4.jar' in directory /opt/bamboo-home/xml-data/build-dir/SPR-SONAR-JOB1/spring-aop
 org.sonar.batch.scan.ProjectReactorBuilder.validateDirectories(ProjectReactorBuilder.java:302)
 org.sonar.batch.scan.ProjectReactorBuilder.loadChildProject(ProjectReactorBuilder.java:217)
 org.sonar.batch.scan.ProjectReactorBuilder.defineChildren(ProjectReactorBuilder.java:192)
 org.sonar.batch.scan.ProjectReactorBuilder.execute(ProjectReactorBuilder.java:116)
 org.sonar.batch.scan.ProjectScanContainer.projectBootstrap(ProjectScanContainer.java:120)
 org.sonar.batch.scan.ProjectScanContainer.doBeforeStart(ProjectScanContainer.java:98)
 org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:91)
 org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:78)
 org.sonar.batch.scan.ScanTask.scan(ScanTask.java:64)
 org.sonar.batch.scan.ScanTask.execute(ScanTask.java:51)
 org.sonar.batch.bootstrap.TaskContainer.doAfterStart(TaskContainer.java:125)
 org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:93)
 org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:78)
 org.sonar.batch.bootstrap.BootstrapContainer.executeTask(BootstrapContainer.java:173)
 org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:95)
 org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
 org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.executeOldVersion(BatchIsolatedLauncher.java:70)
 org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
 com.sun.proxy.$Proxy77.executeOldVersion(Unknown Source)
 org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:238)
 org.sonarsource.scanner.api.EmbeddedScanner.runAnalysis(EmbeddedScanner.java:151)
 org.sonarqube.gradle.SonarQubeTask.run(SonarQubeTask.java:93)
Run Code Online (Sandbox Code Playgroud)

spring-cglib-repack-3.2.4.jar确实存在于spring-core/build/libs/文件夹中,因为我的构建是在自定义jarjar任务中重新打包cglib依赖.

看来该插件正在该spring-aop文件夹下寻找该资源,因此是例外.

请注意,相同的配置适用于2.1版本.

sonarqube sonarqube-scan

6
推荐指数
2
解决办法
7562
查看次数