运行 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) 我在这里关注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具有java与resources在同一水平,如果这不是由ASCII艺术显而易见的.(编辑:现在是.)
映射文件(Employee.hbm.xml)应该放在哪里?该文件在配置文件(hibernate.cfg.xml)中引用.
谢谢您阅读此篇.
问候,
我需要在 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 Time和 PowerMock 的情况下正确实现它?
鉴于两者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) 我在这里面对EL一个奇怪的问题。
我只想在EL中使用String.join(),但是它不起作用。
#{String.join(',', myList)}
Run Code Online (Sandbox Code Playgroud)
除了阻止我的页面加载之外,这在JSF中没有做任何事情。我知道我可以做到这一点,<ui:repeat>但我需要在EL表达式中使用它。
有任何想法吗 ?
当它要求时,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 ('<>')):
如果我Object从内部删除<>,Eclipse仍然不高兴:
我们确保了
java.util.List 是进口的 Project -> Clean... 命令已应用蓝色警告仍然不会消失.