我正在通过一些示例来学习Akka HTTP堆栈以创建新的REST项目(完全非UI).我一直在使用和扩充Akka HTTP微服务示例来处理大量用例和配置,并对Scala和Akka HTTP的工作情况感到惊喜.
目前我有这样的配置:
object AkkaHttpMicroservice extends App with Service {
override implicit val system = ActorSystem()
override implicit val executor = system.dispatcher
override implicit val materializer = ActorMaterializer()
override val config = ConfigFactory.load()
override val logger = Logging(system, getClass)
Http().bindAndHandle(routes, config.getString("http.interface"), config.getInt("http.port"))
}
Run Code Online (Sandbox Code Playgroud)
该routes参数仅具有使用在其内的典型数据的简单值path,pathPrefix等
有没有办法在多个Scala文件或某个地方设置路由?
我真的希望能够定义一组类来分离关注点并处理Actor设置和处理以处理应用程序的不同区域,并将编组保留到根App扩展.
对于我如何使用像@javax.ws.rs.Path("/whatever")我的类这样的注释在Java中做事情,我可能会想太多.如果是这种情况,请随时指出思维方式的变化.
values.yml我的 Helm 图表有一个简单的文件:
DbMigration:
Resources:
requests:
memory: 256Mi
limits:
memory: 512Mi
Run Code Online (Sandbox Code Playgroud)
在我的数据库迁移作业的定义中,我有以下内容:
spec:
activeDeadlineSeconds: 120
template:
spec:
restartPolicy: Never
containers:
- name: myMigrate
image: myRepo/myService:0.0.1
imagePullPolicy: Always
resources:
requests:
{{- range $key, $value := $.Values.DbMigration.Resources.requests }}
{{ $key }}: {{ $value }}
{{- end }}
limits:
{{- range $key, $value := $.Values.DbMigration.Resources.limits }}
{{ $key }}: {{ $value }}
{{- end }}
Run Code Online (Sandbox Code Playgroud)
有什么方法可以简化该resources区域,以便我可以包含来自的所有数据$.Values.DbMigration.Resources?我所拥有的可行,但必须有更简洁的方法。我尝试以toYaml与此类似的方式使用该函数:
{{- toYaml $.Values.DbMigration.Resources }}
Run Code Online (Sandbox Code Playgroud)
然而,这会导致:
错误:升级失败:myTemplate.yaml 上的 YAML 解析错误:将 YAML …
我目前正在 Spring Boot 和 GCP 数据存储中进行一些概念验证工作。
在我的pom.xml我有:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gcp-data-datastore</artifactId>
<version>1.2.6.RELEASE</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
当我尝试启动应用程序时,我得到:
Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/core/metrics/ApplicationStartup
at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:251)
at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:264)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1309)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1298)
Run Code Online (Sandbox Code Playgroud)
我尝试添加执行器,但没有成功,但我无法弄清楚我缺少什么依赖项。我看到的类定义在这里在5.3.0-M2的文档,但我不知道它存在于什么依赖。
我也尝试添加:
我在findjar.com 中搜索,但没有运气。
如果可能的话,我也不介意禁用它。
更新:
我补充说:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>5.3.1</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
这给了我一个新的错误:
试图调用不存在的方法。尝试是从以下位置进行的:
Run Code Online (Sandbox Code Playgroud)org.springframework.boot.SpringApplication.run(SpringApplication.java:324)以下方法不存在:
Run Code Online (Sandbox Code Playgroud)'void org.springframework.context.ConfigurableApplicationContext.setApplicationStartup(org.springframework.core.metrics.ApplicationStartup)'该方法的类 org.springframework.context.ConfigurableApplicationContext 可从以下位置获得:
... 行动:
更正应用程序的类路径,使其包含 org.springframework.context.ConfigurableApplicationContext 的单个兼容版本
我开始从Spring Config开始学习Spring Cloud.我有两个基本问题要让我进入学习过程的下一步(通过Consul继续进行Service Discovery).
/refresh端点以POST?对于#1,我实现了自己的@RestController/ @RequestMapping但没有我之后提到的那些教程.我检查了我的Maven配置,它与样本提供的内容相匹配,但它没有弹出.
我在这里找到了第二个问题的帖子: spring cloud auto refresh config server property.我只是想知道自2015年11月以来是否有任何更新.
这两件事似乎都非常方便,并且会直接与我的Consul学习交织在一起,因为我可以自动将配置更新推送给注册为服务的每个人.一旦我到达那里,我也可以继续重启,但那是后来的事.
我得到了#1的答案.我在我的Maven模块中破坏了我的依赖项配置.在对配置进行三重检查后,结果发现它只是导频错误.仍在努力#2,但是 - 如果有人有任何更新,将不胜感激.
我正在使用IntelliJ(14.0.3)和Wildfly(8).
当我重新编译我的Java类时,热插拔很容易,一切正常.但是,我的HTML,JS和CSS文件不会热交换给我.我确信这只是一个配置问题,并希望得到一些帮助.
我的HTML数据位于:
<root>/<war_module>/src/main/webapp
我的运行/调试设置为:
在发布之前:制作,构建工件
- 使
- 建立'mymodule:war'神器
我有一个简单的指令,执行特定元素的大小更新.这会监视窗口大小并相应地进行调整.
MyApp.directive('resizeTest', ['$window', function($window) {
return {
restrict: 'AC',
link: function(scope, element) {
var w = angular.element($window);
scope.$watch(function() {
return { 'h': w.height(), 'w': w.width() };
}, function(newValue, oldValue) {
// resizing happens here
}, true);
w.bind('resize', function() { scope.$apply(); });
}
};
}]);
Run Code Online (Sandbox Code Playgroud)
这很好用.
恰好在div与之关联的标签内部,我有一个孩子div.调整父级的大小时,我想对子元素进行定位更改.但是,我无法触发.
这会在启动时调用,但在调整元素大小或窗口更改时不会触发:
MyApp.directive('centerVertical', ['$window', function($window) {
return {
restrict: 'AC',
link: function(scope, element) {
element.css({border: '1px solid #0000FF'});
scope.$watch('data.overlaytype', function() {
$window.setTimeout(function() {
console.log('I am: ' + element.width() + 'x' …Run Code Online (Sandbox Code Playgroud) 我想知道AngularJS为一个领域获得标签的"最佳实践"方式是什么.使用jQuery,您只需使用"label for"查询进行查询,然后提取文本.虽然使用AngularJS可以这样做,但事情并不恰到好处.
假设你的HTML中有这样的东西:
<form name="MyForm" ng-controller="Ctrl">
<label for="MyField">My spoon is too big:</label>
<input type="text" size="40" id="MyField" ng-model="myField" />
<br /><br />
You entered {{ myField }} for {{ myField.label }}
</form>
Run Code Online (Sandbox Code Playgroud)
控制器内部非常简单:
$scope.myField = 'I am a banana.';
Run Code Online (Sandbox Code Playgroud)
基本上我想填充myField.label输出与" 我的勺子是太大了. "
我现在所做的就是执行一个查询,提取类似于jQuery方法的数据($("label[for='MyField']")).然后,如果不存在,我只是拉出占位符文本.它有效,但似乎有点开销.
我想要一些自定义表单验证,我想在邮件中包含标签.我只需要拉标签文本,这样我就可以非常一般地编写它,然后不必担心人们在游戏后期动态切换i18n数据.
根据建议的解决方案:https: //jsfiddle.net/rcy63v7t/7/
我有一个我认为是带有 Redis 的 AWS ElastiCache 的简单 Terraform 配置:
resource "aws_elasticache_replication_group" "my_replication_group" {
replication_group_id = "my-rep-group",
replication_group_description = "eln00b"
node_type = "cache.m4.large"
port = 6379
parameter_group_name = "default.redis5.0.cluster.on"
snapshot_retention_limit = 1
snapshot_window = "00:00-05:00"
subnet_group_name = "${aws_elasticache_subnet_group.my_subnet_group.name}"
automatic_failover_enabled = true
cluster_mode {
num_node_groups = 1
replicas_per_node_group = 1
}
}
Run Code Online (Sandbox Code Playgroud)
我尝试使用以下方法定义端点输出:
output "my_cache" {
value = "${aws_elasticache_replication_group.my_replication_group.primary_endpoint_address}"
}
Run Code Online (Sandbox Code Playgroud)
当我通过 terragrunt 运行 apply 时,我得到:
错误:运行计划出错:发生 1 个错误:
module.mod.output.my_cache:资源“aws_elasticache_replication_group.my_replication_group”没有变量“aws_elasticache_replication_group.my_replication_group.primary_endpoint_address”的属性“primary_endpoint_address”
我在这里做错了什么?
amazon-web-services amazon-elasticache terraform redis-cluster
简单的流程要求: 在包中找到的所有扩展名List.classjava.util。
这是我正在使用的来源:
Reflections reflections = new Reflections("java.util");
Set<Class<?>> subtypes = reflections.getSubTypesOf(List.class);
Run Code Online (Sandbox Code Playgroud)
很简单,对吧?
它既可以在IntelliJ IDEA中也可以在Eclipse中使用,但是当我通过Maven运行测试时不起作用。我尝试使用所org.reflections.util.ConfigurationBuilder提供的方法添加内容,以添加URL和过滤包名称,但没有运气。
有什么建议么?
我浏览了这篇文章,但无法正常工作:“ 仅当由Maven执行时,使用Reflections谷歌库的单元测试才会失败 ”
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>ohno</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.10</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.10</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)
Sample.java
package com.example.uhoh;
import org.reflections.Reflections;
import java.util.Set;
public class Sample {
@SuppressWarnings ("unchecked")
public static Set<Class<?>> lookup(Class<?> type) {
Reflections reflections = new Reflections("java.util"); …Run Code Online (Sandbox Code Playgroud) I am learning ReactJS so I am completely new at this.
I created an authentication/authorization service that I know works in React just fine. What I am trying to do is protect the primary application with a login. As I understand, I want a high-order component such as this in order to protect the core of the application:
const withAuth = (Component) => {
const AuthenticatedComponent = () => {
const isAuthenticated = MyService.isUserAuthenticated();
if (!isAuthenticated) {
return <Navigate to="/login" …Run Code Online (Sandbox Code Playgroud) angularjs ×2
spring-boot ×2
akka-http ×1
forms ×1
hotswap ×1
intellij-14 ×1
javascript ×1
labels ×1
maven ×1
maven-3 ×1
reactjs ×1
reflections ×1
scala ×1
spring-cloud ×1
terraform ×1
wildfly ×1
wildfly-8 ×1