我有一个使用的Maven pom <packaging>war</packaging>.但实际上,我不想构建war文件,我只想要收集所有依赖的jar并创建一个完整的部署目录.
所以我正在运行war:exploded生成部署目录的目标:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<configuration>
<webappDirectory>target/${env}/deploy</webappDirectory>
<archiveClasses>true</archiveClasses>
</configuration>
<goals>
<goal>exploded</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
问题是,战争文件仍然建立.是否有一种简单的方法来<packaging>war</packaging>执行war:exploded目标而不是战争:战争目标?
或者还有另一种简单的方法吗?
我已经用C语言编程了几十年了.在某个地方,我决定不再想写:
if (var) // in C
if ($var) # in Perl
Run Code Online (Sandbox Code Playgroud)
当我的意思是:
if (var != 0)
if (defined $var and $var ne '')
Run Code Online (Sandbox Code Playgroud)
我认为部分原因是我有一个强类型的大脑,在我看来,"if"需要一个布尔表达式.
或者也许是因为我使用Perl这么多,Perl中的真相和虚假就是这样一个雷区.
或者也许只是因为这些天,我主要是一名Java程序员.
你有什么偏好?为什么?
我有许多使用Postgres"Partitioning"功能的表.我想在每个表上定义一个常见的BEFORE INSERT OF ROW触发器,1)如果针对父表发生插入,则动态创建分区; 2)对分区重新执行插入.
就像是:
CREATE OR REPLACE FUNCTION partition_insert_redirect( )
RETURNS trigger AS $BODY$
BEGIN
... create the new partition and set up the redirect Rules ...
/* Redo the INSERT dynamically. The new RULE will redirect it to the child table */
EXECUTE 'INSERT INTO ' || quote_ident(TG_TABLE_SCHEMA) || '.' || quote_ident(TG_TABLE_NAME) ||
' SELECT NEW.*'
END
Run Code Online (Sandbox Code Playgroud)
但是在EXECUTE SQL中看不到"NEW"记录.我怎样才能尽可能简单地完成这项工作?
作为替代方案,我可以以某种方式迭代新记录中的字段吗?
我想过使用临时表:
EXECUTE 'CREATE TEMPORARY TABLE new_row (LIKE ' ||
quote_ident(TG_TABLE_SCHEMA) || '.' || quote_ident(TG_TABLE_NAME) ||
') ON …Run Code Online (Sandbox Code Playgroud) 我正在考虑使用Annotations来定义我的Hibernate映射,但遇到了一个问题:我想使用基本实体类来定义公共字段(包括ID字段),但我希望不同的表具有不同的ID生成策略:
@MappedSuperclass
public abstract class Base implements Serializable {
@Id
@Column(name="ID", nullable = false)
private Integer id;
public Integer getId(){return id;}
public void setId(Integer id){this.id = id;}
...
}
@Entity
@Table(name="TABLE_A")
public class TableA extends Base {
// Table_A wants to set an application-defined value for ID
...
}
@Entity
@Table(name="TABLE_B")
public class TableB extends Base {
// How do I specify @GeneratedValue(strategy = AUTO) for ID here?
...
}
Run Code Online (Sandbox Code Playgroud)
有办法做到这一点吗?我已经尝试将以下内容包含在内,TableB但是hibernate反对我有两次相同的列,这似乎是错误的:
@Override // So that we can set …Run Code Online (Sandbox Code Playgroud) 我刚刚重构了我的数据库,以便在Postgres 8.2中使用分区.现在我的查询性能有问题:
SELECT *
FROM my_table
WHERE time_stamp >= '2010-02-10' and time_stamp < '2010-02-11'
ORDER BY id DESC
LIMIT 100;
Run Code Online (Sandbox Code Playgroud)
表中有4500万行.在分区之前,这将使用反向索引扫描并在达到限制时立即停止.
分区后(在time_stamp范围内),Postgres对主表和相关分区进行完整索引扫描并合并结果,对它们进行排序,然后应用限制.这需要太长时间.
我可以解决它:
SELECT * FROM (
SELECT *
FROM my_table_part_a
WHERE time_stamp >= '2010-02-10' and time_stamp < '2010-02-11'
ORDER BY id DESC
LIMIT 100) t
UNION ALL
SELECT * FROM (
SELECT *
FROM my_table_part_b
WHERE time_stamp >= '2010-02-10' and time_stamp < '2010-02-11'
ORDER BY id DESC
LIMIT 100) t
UNION ALL
... and so on ... …Run Code Online (Sandbox Code Playgroud) 使用 java 11 运行 Maven 构建,构建在运行测试时发出以下警告:
[WARNING] Corrupted STDOUT by directly writing to native stream in forked JVM 1. See FAQ web page and the dump file /home/thomas/code/irdeto-control/fps-license-service/fps/target/surefire-reports/2019-04-11T14-05-32_318-jvmRun1.dumpstream
Run Code Online (Sandbox Code Playgroud)
...在构建失败后出现以下 stderr 输出:
$ cat error.message
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.1:test (default-test) on project fps: There are test failures.
[ERROR]
[ERROR] Please refer to /home/user/code/employer-control/fps-license-service/fps/target/surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] The forked VM terminated without properly saying …Run Code Online (Sandbox Code Playgroud) 我一直在掌握Marpa解析器,当第一个符号是可选的时遇到了问题.这是一个例子:
use strict;
use warnings;
use 5.10.0;
use Marpa::R2;
use Data::Dump;
my $grammar = Marpa::R2::Scanless::G->new({source => \<<'END_OF_GRAMMAR'});
:start ::= Rule
Rule ::= <optional a> 'X'
<optional a> ~ a *
a ~ 'a'
END_OF_GRAMMAR
my $recce = Marpa::R2::Scanless::R->new({grammar => $grammar});
dd $recce->read(\"X");
Run Code Online (Sandbox Code Playgroud)
当我运行它时,我收到以下错误:
Error in SLIF parse: No lexemes accepted at line 1, column 1
* String before error:
* The error was at line 1, column 1, and at character 0x0058 'X', ...
* here: X
Marpa::R2 exception at …Run Code Online (Sandbox Code Playgroud) perl ×2
postgresql ×2
annotations ×1
c ×1
coding-style ×1
crash-dumps ×1
fork ×1
hibernate ×1
java ×1
jpa ×1
jvm ×1
marpa ×1
maven ×1
maven-2 ×1
partitioning ×1
performance ×1
plpgsql ×1
sql ×1
triggers ×1