我有以下angular2材料表
<mat-table #table [dataSource]="dataSource" >
<!--- Note that these columns can be defined in any order.
The actual rendered columns are set as a property on the row definition" -->
<!-- Position Column -->
<ng-container matColumnDef="selected">
<mat-header-cell *matHeaderCellDef>
<mat-checkbox [(ngModel)]="selectAll"></mat-checkbox>
</mat-header-cell>
<mat-cell *matCellDef="let element">
<mat-checkbox [(ngModel)]="element.selected" [checked]="selectAll"></mat-checkbox>
</mat-cell>
</ng-container>
<ng-container matColumnDef="id">
<mat-header-cell *matHeaderCellDef> Id</mat-header-cell>
<mat-cell *matCellDef="let element"> {{element.id}}</mat-cell>
</ng-container>
<ng-container matColumnDef="requested_status">
<mat-header-cell *matHeaderCellDef> Status</mat-header-cell>
<mat-cell *matCellDef="let element"> {{element.requested_status}}</mat-cell>
</ng-container>
......
Run Code Online (Sandbox Code Playgroud)
我需要通过一些布尔条件隐藏表中的列.是否可以在不改变组件中的列映射的情况下?
displayedColumns = ['selected', 'id', ...];
Run Code Online (Sandbox Code Playgroud)
我尝试使用,*ngIf但它不起作用.怎么做?
我有一个在服务器X上运行的独立命令行java应用程序.我需要知道运行它的机器的唯一ID.如何获得此ID?也许像哈希一样.我不想保留那里有ID的文件.有没有办法获得这个不依赖于IP,硬件等的唯一ID?
我需要在hibernate中实现以下请求:
insert into my_table(....,max_column)
values(...,(select max(id) from special_table where ....))
Run Code Online (Sandbox Code Playgroud)
如何在hibernate中使用注释来做到这一点?special_table可能不是my_table的子项或依赖项,只是一个subselect.
我希望理解这个概念:
T object - generic,将被删除为实际类型.? 对象 - 会被抹去什么?Object 宾语;之间有什么区别T,?和Object?
我很容易理解#1,但是怎么样:
Object var;
? var;
Run Code Online (Sandbox Code Playgroud)
两者有什么区别?我已经读过,我不能?明确地使用,像T或任何其他变量,并且它?与对象有关,而不是类型.
但实际原因是什么?为什么我不能只写一个List对象(List<Object>)而不是List通配符(List<?>)?因为我不知道两种情况下的对象类型.
另外,我想知道什么是擦除??
我使用ThreadPoolExecutor 如下:
ThreadPoolExecutor pool = new ThreadPoolExecutor(cores, 50, 30L,
TimeUnit.SECONDS, new ArrayBlockingQueue<>(10));
Run Code Online (Sandbox Code Playgroud)
并且:
pool.execute(()->{
//code goes here
if(some condition){
return;
}
//code goes here
})
Run Code Online (Sandbox Code Playgroud)
当启用带有return语句的块时,所有这些任务都会卡在TPE中.TPE说它已经完全加载并且总是抛出RejectedExecutionException异常
我不明白为什么会这样.例如,如果您有一个大小为10的池,并且您有100个任务,其中10个将匹配if section,您将不接受第101个任务,所有下一个任务将被拒绝.为什么?
我编写了以下程序:
import sun.security.action.GetPropertyAction;
import java.security.AccessController;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
public class Main {
public static void main(String[] args) {
System.out.println(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss Z").format(new Date()));
System.out.println(TimeZone.getDefault().getDisplayName());
String country =AccessController.doPrivileged(new GetPropertyAction("user.country"));
System.out.println(country);
String javaHome=AccessController.doPrivileged(new GetPropertyAction("java.home"));
System.out.println(javaHome);
}
}
Run Code Online (Sandbox Code Playgroud)
然后,我在计算机上设置了GMT + 3欧洲/明斯克时区。
如果我使用最新版本的JDK6运行该程序,则会看到它显示我的Java时区是委内瑞拉标准时间GMT + 4.30如果我在最新的JDK7版本上运行它,则它将显示巴西时区GMT-3,如果我运行它在最新的JDK8版本上,它向我显示了莫斯科时间GMT + 3。如果我在Win7计算机上选择了Volgograd GMT + 3时区,则该程序在所有Java版本中均可正常运行。那么这是Minsk时区的JDK中的错误吗?
我有一个包含以下列的表格:
ID,URL,内容
因此,有很多记录包含网址,搜索内容等
我需要在postgres 9.5中编写一个查询,该查询使用我的自定义搜索字符串,例如
“我要搜索bla bla”并在“内容”列中搜索所有可能的条目,然后返回找到匹配项的记录的ID。我可以用它吗
SELECT to_tsvector('fat cats ate fat rats') @@ to_tsquery('fat & rat');
Run Code Online (Sandbox Code Playgroud)
还是为此提供了更高级的工具?另外,如何优雅地将其与spring-data集成?谢谢
我有以下监听方法:
@Override
public void onMessage(Message message, Channel channel) {
try {
// do something bad :)
} catch (Exception e){
try {
long dt = null != message.getMessageProperties()
? message.getMessageProperties().getDeliveryTag()
: 0;
channel.basicReject(dt, true);
} catch(IOException io) {
logger.error("IO-COMMON", io);
}
}
}
Run Code Online (Sandbox Code Playgroud)
问题是基本拒绝不起作用,我不知道为什么.如何优雅地拒绝它?我认为,如果我拒绝一条消息,它应该被重新排队并且驻留就像缓存一样,然后再转到下一个工作者.但实际上这条消息似乎已经丢失了.
我有2个java语句:
if(myvar!=null)
if(null!=myvar)
Run Code Online (Sandbox Code Playgroud)
有人说第二种形式更好,因为它有助于避免NPE,这是真的吗?通常在java中使用什么?
我有一个线程池:
ThreadPoolExecutor pool = new ThreadPoolExecutor(cores, 50, 30L, TimeUnit.SECONDS, new ArrayBlockingQueue<>(3000));
Run Code Online (Sandbox Code Playgroud)
然后我跑:
try {
pool.execute(() ->
{
//Very very long task, fetching from an external URL
});
}catch(Exception e){
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
我从来没有得到过例外,这段代码等了好几分钟.我应该怎么做才能在30秒内取消?
我有以下代码片段:
Boolean var=false;
boolean var1=(var=null);
if(var1){
//it compiles
}
if(var=null){
//it compiles
}
Run Code Online (Sandbox Code Playgroud)
为什么编译?
在Boolean课堂上我发现了以下内容:
public static boolean parseBoolean(String s) {
return ((s != null) && s.equalsIgnoreCase("true"));
}
Run Code Online (Sandbox Code Playgroud)
这是否意味着被null视为false?为什么=操作的结果boolean是false?这种行为的实际原因是什么?
我想创建以下logback配置:
<configuration>
<appender name="INCOMING_REQUESTS_LOG" class="ch.qos.logback.core.FileAppender">
<file>./logs/incoming_requests.log</file>
<append>true</append>
<!-- encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
<pattern>%date %-4relative [%thread] %-5level %logger{35} | %msg%n</pattern>
</encoder>
</appender>
<logger name="mysuperduperlogger" level="DEBUG" additivity="false">
<appender-ref ref="INCOMING_REQUESTS_LOG"/>
</logger>
</configuration>
Run Code Online (Sandbox Code Playgroud)
我可以用吗
logger name="mysuperduperlogger"
Run Code Online (Sandbox Code Playgroud)
作为logback记录器名称以及如何在我的代码中访问它?在文档中我只能找到像"com.mypackage.myclass.aa1"这样的记录器
我有以下Java代码段:
int begin=Integer.MAX_VALUE-10;
int end=Integer.MAX_VALUE;
for(int i=begin;i<=end;i++){
System.out.println("hehe");
}
Run Code Online (Sandbox Code Playgroud)
这个代码片段将无限运行,我可以理解这是因为
i<**=**end
Run Code Online (Sandbox Code Playgroud)
但有些人说int并且Integer有不同的范围.这是真的吗?为什么?
java ×11
angular ×1
generics ×1
hash ×1
hibernate ×1
hql ×1
java-8 ×1
logback ×1
logging ×1
object ×1
orm ×1
postgresql ×1
server ×1
spring ×1
spring-amqp ×1
spring-data ×1
sql ×1
threadpool ×1
timezone ×1
type-erasure ×1
wildcard ×1