我已经创建了一些文档并设法进行了一些简单的查询,但是我无法创建一个可以查找字段存在的文档的查询.
例如,假设这是一个文档:
{ "profile_sidebar_border_color" : "D9B17E" ,
"name" : "???? ???????" , "default_profile" : false ,
"show_all_inline_media" : true , "otherInfo":["text":"sometext", "value":123]}
Run Code Online (Sandbox Code Playgroud)
现在我想要一个查询,它将带来文本所在的所有文档otherInfo.
如果没有文字,那么otherInfo意志就是这样:"otherInfo":[]
所以我想检查一下该text字段的存在otherInfo.
我怎样才能做到这一点?
我有一个反应式表单,并根据fooRequired我想要将字段设置为必填或非必填的属性。
我无法更改它,因为它是初始设置的。那我能做什么呢?
fooRequired = false;
form = new FormGroup({
foo: new FormControl(null, [Validators.required])
});
toggle() { this.fooRequired = !this.fooRequired; }
Run Code Online (Sandbox Code Playgroud) 我对maven有一个小问题.当我运行命令mvn包时,我收到以下警告:
[警告] JAR将为空 - 没有内容标记为包含!
构建成功但生成的jar文件为空,如警告所示.
为什么这样,我做错了什么?
这是我的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
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>framework</groupId>
<artifactId>framework</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>framework</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
My dependencies
</dependencies>
<build>
<directory>target</directory>
<outputDirectory>target/classes</outputDirectory>
<finalName>${project.artifactId}-${project.version}</finalName>
<testOutputDirectory>target/test-classes</testOutputDirectory>
<sourceDirectory>src</sourceDirectory>
<scriptSourceDirectory>src</scriptSourceDirectory>
<testSourceDirectory>src</testSourceDirectory>
<testResources>
<testResource>
<directory>test</directory>
</testResource>
</testResources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<includes>
<include>src</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<outputDirectory>lib</outputDirectory>
</configuration>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
我的应用程序目前使用Spring Session和Redis作为后端.
我搜索了Spring Session 的官方文档,但是在使用该模块时无法找到默认会话超时.
此外,我不知道如何在必要时更改默认超时.
有人可以建议吗?
为什么会出错?我以为map可以回报任何价值.
var s = IntStream.rangeClosed(1, 5).map(String::valueOf).collect(Collectors.toList());
Run Code Online (Sandbox Code Playgroud)
| 错误:| 不兼容的类型:方法引用中的错误返回类型| java.lang.String无法转换为int | var s = IntStream.rangeClosed(1,5).map(String :: valueOf).collect(Collectors.toList()); |
^ ^ -------------
我使用以下Smarty代码:
{foreach from=$entries key=i item=topic}
{if $topic.topic_style == question}
<li>
<a href="topic.php?id={$topic.id}">{$topic.title}</a>
</li>
{/if}
{/foreach}
Run Code Online (Sandbox Code Playgroud)
我怎样才能{foreach}最多10次然后停止?
我正在学习Angular 2.在角度2生命周期钩子里
ngAfterContentInit -- Component content has been initialized
ngAfterContentChecked -- Component content has been Checked
ngAfterViewInit -- Component views are initialized
ngAfterViewChecked -- Component views have been checked
Run Code Online (Sandbox Code Playgroud)
我无法理解ngAfterContentInit与ngAfterContentChecked,ngAfterViewInit和ngAfterViewChecked之间的区别.
他们提到组件内容已经过检查,并且已经检查了组件视图.我不明白"Checked"这个词提到了什么?
任何人都可以解释.
我正在尝试重现可以在RabbitMQ主页中找到的Java发布者的第一个示例.
首先,我用Java做了它并且工作正常.然后,我在Android上尝试了它,这里是奇怪部分的来源.
我手动添加了我在Java程序中使用的jar库,这些库是在RabbitMQ教程中建议的.也就是说amqp-client-5.4.1,slf4j-api-1.7.21并将slf4j-simple-1.7.22其添加到/libs目录中,然后在buid.gradle (module:app)命令中引用implementation files('libs/amqp-client-5.4.1.jar'),依此类推.
然后,我在我的MainActivity.java文件中添加了所需的包依赖项,而没有遇到任何错误.但是,在添加应该发布数据的代码片段时,找不到导入库的不同方法,例如,factory因为它没有该方法setHost.
我附上我正在使用的代码.
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import java.io.IOException;
import java.util.concurrent.TimeoutException;
import com.rabbitmq.client.ConnectionFactory;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.Channel;
public class MainActivity extends AppCompatActivity {
String QUEUE_NAME = "hello";
ConnectionFactory factory = new ConnectionFactory();
factory.setHost("192.0.0.0"); //Marked as error
factory.setUsername("test");
factory.setPassword("test");
Connection connection;
Channel channel;
connection = factory.newConnection();
channel = connection.createChannel();
channel.queueDeclare(QUEUE_NAME, false, false, false, null);
String message = …Run Code Online (Sandbox Code Playgroud) 嗨,我是Docker的新手,并尝试从头开始编写新图像.我正在编写这个dockerFile来编译和运行同一目录中可用的简单java程序.
这是dockerfile.
FROM scratch
CMD javac HelloWorld.java
CMD java HelloWorld
Run Code Online (Sandbox Code Playgroud)
Docker构建成功,如下所示
[root@hadoop01 myjavadir]# docker build -t runhelloworld .
Sending build context to Docker daemon 3.072 kB
Sending build context to Docker daemon
Step 0 : FROM scratch
--->
Step 1 : CMD javac HelloWorld.java
---> Running in 7298ad7e902f
---> f5278ae25f0c
Removing intermediate container 7298ad7e902f
Step 2 : CMD java HelloWorld
---> Running in 0fa2151dc7b0
---> 25453e89b3f0
Removing intermediate container 0fa2151dc7b0
Successfully built 25453e89b3f0
Run Code Online (Sandbox Code Playgroud)
但是当我尝试运行时,它会抛出以下错误:
[root@hadoop01 myjavadir]# docker run runhelloworld
exec: …Run Code Online (Sandbox Code Playgroud)