我一直在使用Zuul作为边缘服务和API网关.最近我注意到Spring Cloud Platform发布了Spring Cloud Gateway.这两个网关有什么区别?为什么Zuul没有扩展到支持SC-Gateway的功能?一个新图书馆的驱动因素是什么?什么时候应该使用?
我正在使用spring-boot-starter-parent版本2.0.1.RELEASE开发Spring Cloud项目.
我低于警告,看起来像
属性"security.basic.enabled"已弃用:安全自动配置不再可自定义.请改为提供您自己的WebSecurityConfigurer bean.
security:basic:enabled:在Spring安全最新版本中禁用false.
你能指导一下我应该用什么代替吗?
application.yml
---
server:
port: 8888
security:
basic:
enabled: false
spring:
cloud:
config:
server:
git:
uri: https://github.com/rseroter/pluralsight-spring-cloudconfig-wa-tolls
search-paths:
- 'station*'
repos:
perf:
pattern:
- '*/perf'
uri: https://github.com/rseroter/pluralsight-spring-cloudconfig-wa-tolls-perf
search-paths:
- 'station*'
Run Code Online (Sandbox Code Playgroud)
的pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.1.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-cloud.version>Finchley.BUILD-SNAPSHOT</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency> …
Run Code Online (Sandbox Code Playgroud) 我正在使用 spring cloud 将模块化应用程序迁移到微服务应用程序,当我完成将模块迁移到微服务并运行它时,出现了一个问题:
更正应用程序的类路径,使其包含 org.springframework.plugin.core.PluginRegistry 的单个兼容版本
这是错误:
试图调用不存在的方法。尝试是从以下位置进行的: org.springframework.data.rest.core.support.UnwrappingRepositoryInvokerFactory.<init>(UnwrappingRepositoryInvokerFactory.java:57) 以下方法不存在: org.springframework.plugin.core.PluginRegistry.of(Ljava/util/List;)Lorg/springframework/plugin/core/PluginRegistry; 该方法的类 org.springframework.plugin.core.PluginRegistry 可从以下位置获得: jar:file:/~/.m2/repository/org/springframework/plugin/spring-plugin-core/1.2.0.RELEASE/spring-plugin-core-1.2.0.RELEASE.jar!/org/springframework/plugin /core/PluginRegistry.class 它是从以下位置加载的: 文件:/~/.m2/repository/org/springframework/plugin/spring-plugin-core/1.2.0.RELEASE/spring-plugin-core-1.2.0.RELEASE.jar 行动: 更正应用程序的类路径,使其包含 org.springframework.plugin.core.PluginRegistry 的单个兼容版本
这是我的 pom.xml :
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <父> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.3.0.RELEASE</version> <relativePath/> <!-- 从存储库中查找父级 --> </父> <groupId>org.sid</groupId> <artifactId>SF-postpros</artifactId> <version>0.0.1-SNAPSHOT</version> <name>SF-postpros</name> <description>Spring Boot 演示项目</description> <属性> <java.version>1.8</java.version> <spring-cloud.version>Hoxton.SR4</spring-cloud.version> </属性> <依赖> <依赖> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> <排除> <排除> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-logging</artifactId> </排除> </排除> </依赖> <依赖> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> <scope>运行时</scope> </依赖> <依赖> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </依赖> <依赖> <groupId>javax.validation</groupId> <artifactId>validation-api</artifactId> <version>2.0.1.Final</version> </依赖> <依赖> <groupId>com.querydsl</groupId> <artifactId>querydsl-apt</artifactId> …
我正在使用spring cloud eureka和spring cloud zuul proxy,我想知道是否有任何方法可以在eureka服务器中注册新服务时添加dymanic zuul路由,或者添加路由的唯一方法是编辑application.yml文件和重启spring zuul应用程序
zuul:
ignoredPatterns: /**/admin/**
routes:
users: /myusers/**
Run Code Online (Sandbox Code Playgroud) 我为feignClients启用了我的spring cloud,如下所示:
@Configuration
@EnableAutoConfiguration
@RestController
@EnableEurekaClient
@EnableCircuitBreaker
@EnableFeignClients
public class SpringCloudConfigClientApplication {
}
Run Code Online (Sandbox Code Playgroud)
但是当我添加enableFeignClients时,我在编译期间遇到了这个错误,
java.lang.NoClassDefFoundError: feign/Logger
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2688)
at java.lang.Class.getDeclaredMethods(Class.java:1962)
Run Code Online (Sandbox Code Playgroud)
我的POM是
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-parent</artifactId>
<version>1.0.0.RELEASE</version>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<start-class>demo.SpringCloudConfigClientApplication</start-class>
<java.version>1.7</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix</artifactId>
</dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud)
为了解决假装记录器问题,我需要将哪些其他依赖项添加到POM中?
谢谢
谢谢@spencergibb,基于你的建议,它在我改变我的pom之后起作用了.现在我有另一个使用FeignClient的问题.请看下面:
@Autowired
StoreClient storeClient;
@RequestMapping("/stores")
public List<Store> stores() {
return storeClient.getStores();
}
Run Code Online (Sandbox Code Playgroud)
和界面是:
@FeignClient("store")
public interface StoreClient {
@RequestMapping(method = RequestMethod.GET, value …
Run Code Online (Sandbox Code Playgroud) 我在Spring Cloud项目中遇到错误.在这个项目中,除了从GIT读取.properties文件之外,我没有做任何特别的事情.
请指导这里需要纠正的其他内容?
java.lang.IllegalStateException: Failed to load property source from location 'classpath:/application.yml'
at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:535) ~[spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.loadForFileExtension(ConfigFileApplicationListener.java:494) ~[spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:462) ~[spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.lambda$null$4(ConfigFileApplicationListener.java:444) ~[spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at java.lang.Iterable.forEach(Unknown Source) ~[na:1.8.0_151]
at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.lambda$load$5(ConfigFileApplicationListener.java:443) ~[spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at java.lang.Iterable.forEach(Unknown Source) ~[na:1.8.0_151]
at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:440) ~[spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:331) ~[spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.boot.context.config.ConfigFileApplicationListener.addPropertySources(ConfigFileApplicationListener.java:213) ~[spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.boot.context.config.ConfigFileApplicationListener.postProcessEnvironment(ConfigFileApplicationListener.java:196) ~[spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEnvironmentPreparedEvent(ConfigFileApplicationListener.java:183) ~[spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEvent(ConfigFileApplicationListener.java:169) ~[spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:74) ~[spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54) ~[spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:358) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:317) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at …
Run Code Online (Sandbox Code Playgroud) 我是eureka客户端负载均衡的关注指南:
https://spring.io/guides/gs/client-side-load-balancing/
但是当我有3个服务器实例后,我关闭了其中任何一个,我得到了连接拒绝异常.客户端仍在尝试向这些服务器发送请求,而不是忽略ping失败的服务器.当客户端尝试向这些服务器发送请求时,我会在这些服务器被ping时遇到异常并且出现相同的异常.似乎功能区正在通过配置中列出的所有服务器执行某种盲目的循环,它忽略了我关闭的服务器.
application.yml
spring:
application:
name: user
server:
port: 8888
say-hello:
ribbon:
eureka:
enabled: false
listOfServers: localhost:8090,localhost:9092,localhost:9999
ServerListRefreshInterval: 15000
Run Code Online (Sandbox Code Playgroud)
SayHelloConfiguration.java
package hello;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import com.netflix.client.config.IClientConfig;
import com.netflix.loadbalancer.IPing;
import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.PingUrl;
import com.netflix.loadbalancer.AvailabilityFilteringRule;
public class SayHelloConfiguration {
@Autowired
IClientConfig ribbonClientConfig;
@Bean
public IPing ribbonPing(IClientConfig config) {
return new PingUrl();
}
@Bean
public IRule ribbonRule(IClientConfig config) {
return new AvailabilityFilteringRule();
}
}
Run Code Online (Sandbox Code Playgroud)
UserApplication.java
package hello;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; …
Run Code Online (Sandbox Code Playgroud) load-balancing spring-boot spring-cloud spring-cloud-netflix
是否存在任何组件可以监视服务器、资源或其他 Docker 实例的使用情况,并在需要更多资源时启动新的 Docker 容器?
Docker 容器可能会也可能不会部署在同一台服务器上。
例如 :
1)当消息队列增长太快时,侦听该队列的其他 Docker 容器将启动以帮助消费消息。
2)当通过负载均衡器向服务器发出太多请求时,会运行其他docker实例。
我有一个 spring boot 项目,所以我设置了休眠记录器来记录请求中的所有查询,如下所示:
在我的 application.properties 文件中
logging.level.org.hibernate.type=trace
logging.level.org.hibernate.SQL=debug
logging.level.org.hibernate.type.descriptor.sql.BasicBinder=trace
Run Code Online (Sandbox Code Playgroud)
这很好用,我的所有请求都显示了休眠查询的日志。
但我也有一个计划任务,每秒钟运行一次,如下所示:
@Scheduled(cron = "${* * * * * *}")
public void task() {
...
}
Run Code Online (Sandbox Code Playgroud)
因此,我想仅为此任务执行关闭休眠查询日志,以避免弄乱我的请求输出日志。
我怎样才能设置记录器来做到这一点?!谢谢。
我正在尝试SqsListener
工作,但 Spring Boot 3 做不到,它根本没有收到任何东西。当我将 Spring Boot 版本更改回 2.X 时,一切都工作正常。我使用的是 Spring Cloud 2.4.2 版本:
...
<dependency>
<groupId>io.awspring.cloud</groupId>
<artifactId>spring-cloud-starter-aws-messaging</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.awspring.cloud</groupId>
<artifactId>spring-cloud-aws-dependencies</artifactId>
<version>2.4.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Run Code Online (Sandbox Code Playgroud)
您能给我指出正确的 spring cloud 版本吗?我需要使用里程碑版本吗?
spring-boot ×6
spring-cloud ×5
java ×4
netflix-zuul ×2
spring ×2
amazon-sqs ×1
docker ×1
spring-mvc ×1
springfox ×1
swagger ×1