小编Kir*_*kow的帖子

Spring云网关;在类路径中发现 Spring MVC,与 Spring Cloud Gateway 问题不兼容

运行 API-GATEWAY 时出现以下错误,我尝试了很多方法但无法解决此问题。

描述:

在类路径中发现 Spring MVC,与 Spring Cloud Gateway 不兼容。

行动:

请设置 spring.main.web-application-type=reactive 或删除 spring-boot-starter-web 依赖。

主班

package com.sample.apigateway;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;

@SpringBootApplication
@EnableEurekaClient
public class ApiGatewayApplication {

    public static void main(String[] args) {
        SpringApplication.run(ApiGatewayApplication.class, args);
    }

}
Run Code Online (Sandbox Code Playgroud)

应用程序.yml

spring:
  application:
    name: GATEWAY-SERVICE

  cloud:
    gateway:
      routes:
        - id: USER-SERVICE
          uri: lb://USER-SERVICE
          predicates:
            - Path=/users/**
        - id: DEPARTMENT-SERVICE
          uri: lb://DEPARTMENT-SERVICE
          predicates:
            - Path=/departments/**

eureka:
  client:
    register-with-eureka: true
    fetch-registry: true
    service-url:
      defaultZone: http://localhost:8761/eureka/

  instance:
    hostname: localhost

server:
  port: …
Run Code Online (Sandbox Code Playgroud)

spring-boot spring-webflux spring-cloud-gateway

21
推荐指数
2
解决办法
3万
查看次数

Hibernate教程 - 在何处放置映射文件?

我在这里关注hibernate这个有趣的教程:http://www.tutorialspoint.com/hibernate/hibernate_native_sql.htm

但是,本教程忽略了提到放置这些文件的位置.我正在使用基本Maven项目的文件夹结构.

文件夹结构如下:

foo
????src
    ????main
        ????java
        ?   ????org
        ?       ????me
        ?           ????bar 
        ?               ????[all my java source-files here]
        ????resources
            ????hibernate.cfg.xml
            ????hiber
                ????Employee.hbm.xml
Run Code Online (Sandbox Code Playgroud)

该文件夹main具有javaresources在同一水平,如果这不是由ASCII艺术显而易见的.(编辑:现在是.)

映射文件(Employee.hbm.xml)应该放在哪里?该文件在配置文件(hibernate.cfg.xml)中引用.

谢谢您阅读此篇.

问候,

java hibernate maven

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

如何使用 EasyMock、没有 Joda Time 和 PowerMock 在 Java 8 Web 应用程序中将当前系统时间覆盖为特定日期?

我需要在 Java 8 中模拟时间(到特定日期,这意味着我可能不会使用anyLong())以java.time在 EasyMock 下的测试环境中单独使用,因此没有 Joda Time。

EasyMock 不允许你模拟像LocalDateTime.now(). PowerMock 可以,但我不允许使用 PowerMock。

Joda Time 库提供了一种简洁优雅的方式来模拟时间DateTimeUtils.setCurrentMillisFixed(),并DateTimeUtils.setCurrentMillisSystem()回到现在的瞬间。

只有我不允许使用 Joda Time。

我被告知使用模拟时钟java.time.Clock类实例并将其注入LocalDateTime.now()如下:LocalDateTime.now(mockClock)

有没有办法在没有 Joda TimePowerMock 的情况下正确实现它?

junit easymock junit4 java-8 java-time

5
推荐指数
1
解决办法
2541
查看次数

java.time.Clock.systemDefaultZone().getZone() 与 java.util.TimeZone.getDefault().toZoneId() 之间有什么区别?

鉴于两者java.time.Clock.systemDefaultZone().getZone()java.util.TimeZone.getDefault().toZoneId()返回相同的输出,两者之间有什么区别吗?

例如这段代码

import java.time.Clock;
import java.util.TimeZone;

public class Main {

  public static void main(String[] args) {
    System.out.println("Clock.systemDefaultZone().getZone() : " 
        + Clock.systemDefaultZone().getZone());
    System.out.println("TimeZone.getDefault().toZoneId() : " 
        + TimeZone.getDefault().toZoneId());
  }

}
Run Code Online (Sandbox Code Playgroud)

返回此输出

Clock.systemDefaultZone().getZone() : Europe/Paris
TimeZone.getDefault().toZoneId() : Europe/Paris
Run Code Online (Sandbox Code Playgroud)

java timezone java-8 java-time

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

在EL中使用静态方法

我在这里面对EL一个奇怪的问题。

我只想在EL中使用String.join(),但是它不起作用。

#{String.join(',', myList)}
Run Code Online (Sandbox Code Playgroud)

除了阻止我的页面加载之外,这在JSF中没有做任何事情。我知道我可以做到这一点,<ui:repeat>但我需要在EL表达式中使用它。

有任何想法吗 ?

jsf static-methods el

2
推荐指数
1
解决办法
4435
查看次数

Eclipse警告"在Java项目中使用菱形运算符('<>')替换此构造函数调用中的类型规范

当它要求时,Eclipse意味着什么Replace the type specification in this constructor call with the diamond operator ('<>'),因为所述运算符已经存在?

然后我将光标放在带蓝色下划线的内容上,然后按下F2以了解更多内容,我收到此消息(Replace the type specification in this constructor call with the diamond operator ('<>')):

Eclipse警告说')"">

如果我Object从内部删除<>,Eclipse仍然不高兴:

Eclipse警告说')"">

编辑

我们确保了

  • java.util.List 是进口的
  • 更改已保存
  • Project -> Clean... 命令已应用

蓝色警告仍然不会消失.

java eclipse java-8 sonarlint sonarlint-eclipse

0
推荐指数
1
解决办法
5508
查看次数