我有以下两种方式
public class ObjectA {
int id ;
String name;
}
public class objectB {
Long id;
String name;
}
Run Code Online (Sandbox Code Playgroud)
我希望能够创建一个将由这两个对象实现的接口'AnObject'.这个界面怎么样?
public interface AnObject {
public <type?> getId() ;
public String getName();
}
Run Code Online (Sandbox Code Playgroud)
ID的getter中的类型应该是什么?
我遇到了以下错误
java.lang.NoSuchFieldError: WRITE_DURATIONS_AS_TIMESTAMPS
at com.fasterxml.jackson.datatype.joda.ser.DurationSerializer.<init>(DurationSerializer.java:28)
at com.fasterxml.jackson.datatype.joda.ser.DurationSerializer.<init>(DurationSerializer.java:25)
at com.fasterxml.jackson.datatype.joda.JodaModule.<init>(JodaModule.java:45)
Run Code Online (Sandbox Code Playgroud)
我检查了看哪些版本的jackson-datatype-joda可用.似乎maven排除了所有版本不匹配.
这可能导致序列化错误的任何其他原因?
我正在尝试为我的 覆盖提到的方法HashSet
:
Set<MyObject> myObjectSet = new HashSet<MyObject>();
Run Code Online (Sandbox Code Playgroud)
我的对象:
public class MyObject implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Long id;
String name;
int number;
Map<String,String> myMap;
public MyObject(String name, int number, Map<String,String> myMap) {
this.name = name;
this.number = number;
this.myMap = myMap;
}
[...]
}
Run Code Online (Sandbox Code Playgroud)
如何覆盖 hashcode()、equals() 和 compareTo() 方法?
目前我有以下几点:
public int hashCode () {
return id.hashCode();
}
// override the equals method.
public boolean equals(MyObject s) {
return …
Run Code Online (Sandbox Code Playgroud) I have a multi-module project in Gradle.
I refactored the common functionality into a module named common
.
I have tests in a different module (lets say module A
) of the multi-module project that consume the classes under src/main/java
of the common
module.
I am able to import these classes from common
module in test classes of module A
, but when I run the tests, I get the following error:
error: package 'common.bla...' does not exist.
This is …
我有以下配置作为我的 EC2 实例的用户数据的一部分生成
{
"agent": {
"run_as_user": "root"
},
"logs": {
"logs_collected": {
"files": {
"collect_list": [
{
"file_path": "/var/log/hapee-2.0/lb-access*",
"log_group_name" : <insert-region-here>
"log_stream_name": "haproxy-{instance_id}"
}
]
}
}
},
"metrics": {
"metrics_collected": {
"net": {
"measurement": [
"net_packets_recv",
"net_packets_sent"
],
"metrics_collection_interval": 60
},
"mem": {
"measurement": [
"used_percent"
]
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
因为log_group_name
我希望能够附加region
实例正在运行的内容。我知道该区域是实例元数据的一部分,但我可以在 cloudwatch 配置中使用它吗?
environment-variables amazon-ec2 amazon-cloudwatch aws-regions
我正在尝试运行由maven shade插件创建的jar.我按以下方式配置主类:
<project>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>org.comany.MainClass</Main-Class>
<Build-Number>123</Build-Number>
</manifestEntries>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
Run Code Online (Sandbox Code Playgroud)
...
但是当我尝试使用java -jar app.jar运行jar时,它会出现以下错误
"no main manifest attribute, in app.jar"
Run Code Online (Sandbox Code Playgroud)
编辑:我使用jar tf app.jar检查了jar的内容,我看到了一个MANIFEST.MF文件.BUt它没有主类的条目.如何确保jar中的清单文件将此条目分开,以便在树荫插件配置中添加它?
我有一个非单身演员正在创建一个我想只创建一次的对象.这是如何实现的?演员可以单身吗?如果有,怎么样?
class NonSingletonActor extends UntypedActor {
public static onReceive(Object arg) throws Exception {
*block of code that needs to be executed once!*
} }
Run Code Online (Sandbox Code Playgroud) 我在本地数据库上进行了迁移,一切顺利。我正在为同一模式的另一个数据库使用另一个.yml文件,但由于错误而失败
! com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'myTable' already exists
Run Code Online (Sandbox Code Playgroud)
我该如何进行这项工作?
liquibase包装器是否适用于mysql模式?我能够使用此文档转储迁移http://www.dropwizard.io/0.7.1/docs/manual/migrations.html
这是migrations.xml文件
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.3.xsd http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
<changeSet author="(generated)" id="1501263805585-1">
<createTable catalogName="deployer" schemaName="deployer" tableName="AuthData">
<column autoIncrement="true" name="id" type="BIGINT">
<constraints primaryKey="true"/>
</column>
</createTable>
</changeSet>
<changeSet author="(generated)" id="1501263805585-2">
<createTable catalogName="deployer" schemaName="deployer" tableName="DeployStatus">
<column autoIncrement="true" name="id" type="BIGINT">
<constraints primaryKey="true"/>
</column>
<column name="message" type="VARCHAR(255)"/>
<column name="statusDate" type="VARCHAR(255)"/>
<column name="statusType" type="VARCHAR(255)"/>
<column name="deploy_id" type="BIGINT"/>
</createTable>
</changeSet>
<changeSet author="(generated)" id="1501263805585-3">
<createTable catalogName="deployer" schemaName="deployer" tableName="Service">
<column autoIncrement="true" name="id" type="BIGINT">
<constraints primaryKey="true"/> …
Run Code Online (Sandbox Code Playgroud) 我在这里从文档中遵循这个例子
这是我正在使用的有限状态机的一部分
startWith(ACCEPTED, new myData());
when(ACCEPTED, matchEvent(someMesage.class, MyData.class,
(someMessage, myData) -> goTo(EVALUATING).replying(EVALUATING)));
onTransition(matchState(ACCEPTED,EVALUATING, () -> {
// Here I want to update the nextState data and pass it to another actor
// But the nextState data is always the unititalized object which is new Mydata() when the FSM initializes
}));
whenUnhandled(matchAnyEvent(
(state, data) -> stay().replying("received unhandled request " + state.toString())));
initialize();
}
Run Code Online (Sandbox Code Playgroud)
如何在状态机中的各种状态之间正确传递数据?
如果actor向此FSM actor发送消息,actor.tell调用应该如何
如果我发送以下消息
MyFSM.tell(new someMessage(myData), getSelf());
Run Code Online (Sandbox Code Playgroud)
它正确匹配事件,并且actor将状态更改为EVALUATING
并发回EVALUATING
消息.坚持我真正想要的是,根据状态变化和转换修改'myData',将此修改后的数据发送给另一个actor.
但是当我发送类型为someMessage
I 的消息时,无法发送myData的现有实例,并且它始终未初始化为状态机初始化的一部分. …
我的一个应用程序有以下入口资源
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name:""
annotations:
ingress.kubernetes.io..
spec:
rules:
- host: my-app
http:
paths:
- path: /path/to/service
backend:
serviceName: my-service
servicePort: 80
Run Code Online (Sandbox Code Playgroud)
这按预期工作,我可以在http://my-app/path/to/service
. 但是,我的应用程序中的服务采用似乎没有正确重定向的查询参数,例如:
http://my-app/path/to/service/more/paths
Run Code Online (Sandbox Code Playgroud)
这让我回到 http://my-app/path/to/service
我怎样才能维护这个路径结构?
java ×6
akka ×2
dropwizard ×2
maven ×2
amazon-ec2 ×1
aws-regions ×1
equals ×1
fsm ×1
gradle ×1
hashcode ×1
hashset ×1
hibernate ×1
interface ×1
jar ×1
kubernetes ×1
liquibase ×1
manifest ×1
multi-module ×1
mysql ×1
path ×1