小编wbj*_*wbj的帖子

使用jackson反序列化为自定义对象的HashMap

我有以下课程:

import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.annotate.JsonProperty;

import java.io.Serializable;
import java.util.HashMap;

@JsonIgnoreProperties(ignoreUnknown = true)
public class Theme implements Serializable {

    @JsonProperty
    private String themeName;

    @JsonProperty
    private boolean customized;

    @JsonProperty
    private HashMap<String, String> descriptor;

    //...getters and setters for the above properties
}
Run Code Online (Sandbox Code Playgroud)

当我执行以下代码时:

    HashMap<String, Theme> test = new HashMap<String, Theme>();
    Theme t1 = new Theme();
    t1.setCustomized(false);
    t1.setThemeName("theme1");
    test.put("theme1", t1);

    Theme t2 = new Theme();
    t2.setCustomized(true);
    t2.setThemeName("theme2");
    t2.setDescriptor(new HashMap<String, String>());
    t2.getDescriptor().put("foo", "one");
    t2.getDescriptor().put("bar", "two");
    test.put("theme2", t2);
    String json = "";
    ObjectMapper mapper = objectMapperFactory.createObjectMapper(); …
Run Code Online (Sandbox Code Playgroud)

java jackson json-deserialization

47
推荐指数
2
解决办法
5万
查看次数

与Tomcat 7的相互认证

我正在尝试设置在Tomcat 7中运行的Java Web服务以使用相互(双向)身份验证.似乎无论我做什么,连接到安全端口上的服务都无法正常工作.

这是我创建证书和密钥库所做的事情:

//create the key and certificate for the tomcat server.
keytool -genkey -v -alias tomcat -keyalg RSA -validity 3650 -keystore tomcat.keystore

//create the key and certificate for the client machine.
keytool -genkey -v -alias clientkey -keyalg RSA -storetype PKCS12 -keystore client.p12

//export the client key
keytool -export -alias clientkey -keystore client.p12 -storetype PKCS12 -rfc -file client.cer

//import the client key into the server keystore
keytool -import -v -file client.cer -keystore tomcat.keystore
Run Code Online (Sandbox Code Playgroud)

这是server.xml文件中的连接器:

<Connector port="8443"
    maxThreads="150"
    scheme="https"
    secure="true" …
Run Code Online (Sandbox Code Playgroud)

java ssl tomcat mutual-authentication

17
推荐指数
1
解决办法
3万
查看次数

禁止Nuget.exe的警告输出

我想知道我是否可以在nuget.exe pack命令的输出中禁止警告消息?具体的消息会很棒,但我可以忍住压抑所有这些消息.

nuget 命令行文档提到了Verbosity标志,但从未真正指定它的有效值.我尝试过以下方法:

nuget pack mypackage.nuspec -Verbosity Quiet
Run Code Online (Sandbox Code Playgroud)

但似乎没有做任何事情.

这是我试图打包的nuspec的一个例子:

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
    <metadata>
        <id>MyPackage</id>
        <version>1.0.0</version>
        <authors>Administrator</authors>
        <requireLicenseAcceptance>false</requireLicenseAcceptance>
        <description>My package description.</description>
    </metadata>
    <files>
        <file src="mysourcepath\foo.dll" target="mytargetpath\foo.dll" />
    </files>
</package>
Run Code Online (Sandbox Code Playgroud)

我得到的警告信息是这样的:

WARNING: 1 issue(s) found with package 'MyPackage'.

Issue: Assembly outside lib folder.
Description: The assembly 'mytargetpath\foo.dll' is not inside the 'lib' folder and hence it won't be added as a reference when the package is installed into a project.
Solution: Move it into the 'lib' folder …
Run Code Online (Sandbox Code Playgroud)

nuget octopus-deploy

7
推荐指数
2
解决办法
2259
查看次数