本文整理汇总了Java中com.fasterxml.jackson.annotation.PropertyAccessor类的典型用法代码示例。如果您正苦于以下问题:Java PropertyAccessor类的具体用法?Java PropertyAccessor怎么用?Java PropertyAccessor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PropertyAccessor类属于com.fasterxml.jackson.annotation包,在下文中一共展示了PropertyAccessor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: redisTemplate
import com.fasterxml.jackson.annotation.PropertyAccessor; //导入依赖的package包/类
@Bean(name="redisTemplate")
public RedisTemplate<String, String> redisTemplate(RedisConnectionFactory factory) {
RedisTemplate<String, String> template = new RedisTemplate<>();
RedisSerializer<String> redisSerializer = new StringRedisSerializer();
Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
ObjectMapper om = new ObjectMapper();
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
jackson2JsonRedisSerializer.setObjectMapper(om);
template.setConnectionFactory(factory);
//key序列化方式
template.setKeySerializer(redisSerializer);
//value序列化
template.setValueSerializer(jackson2JsonRedisSerializer);
//value hashmap序列化
template.setHashValueSerializer(jackson2JsonRedisSerializer);
return template;
}
示例2: initializeObjectMapper
import com.fasterxml.jackson.annotation.PropertyAccessor; //导入依赖的package包/类
@Override
protected ObjectMapper initializeObjectMapper() {
final ObjectMapper mapper = super.initializeObjectMapper();
final FilterProvider filters = new SimpleFilterProvider()
.addFilter("beanObjectFilter", new CasSimpleBeanObjectFilter());
mapper.setFilters(filters);
mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
mapper.configure(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS, false);
mapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false);
mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
mapper.addMixIn(Object.class, CasSimpleBeanObjectFilter.class);
mapper.disable(SerializationFeature.INDENT_OUTPUT);
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
return mapper;
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:20,代码来源:InternalConfigStateController.java
示例3: objectMapper
import com.fasterxml.jackson.annotation.PropertyAccessor; //导入依赖的package包/类
public static ObjectMapper objectMapper() {
return new ObjectMapper()
// Property visibility
.setDefaultPropertyInclusion(JsonInclude.Include.ALWAYS)
.setDefaultVisibility(JsonAutoDetect.Value.construct(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.PROTECTED_AND_PUBLIC))
.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true)
.setSerializationInclusion(JsonInclude.Include.NON_NULL)
.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, true)
// Property naming and order
.setPropertyNamingStrategy(PropertyNamingStrategy.LOWER_CAMEL_CASE)
// Customised de/serializers
// Formats, locals, encoding, binary data
.setDateFormat(new SimpleDateFormat("MM/dd/yyyy"))
.setDefaultPrettyPrinter(new DefaultPrettyPrinter())
.setLocale(Locale.CANADA);
}
示例4: redisTemplate
import com.fasterxml.jackson.annotation.PropertyAccessor; //导入依赖的package包/类
/**
* RedisTemplate配置
* @param factory
* @return
*/
@Bean
@SuppressWarnings({"rawtypes", "unchecked"})
public RedisTemplate<String, String> redisTemplate(RedisConnectionFactory factory) {
StringRedisTemplate template = new StringRedisTemplate(factory);
//定义value的序列化方式
Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
ObjectMapper om = new ObjectMapper();
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
jackson2JsonRedisSerializer.setObjectMapper(om);
template.setValueSerializer(jackson2JsonRedisSerializer);
template.setHashValueSerializer(jackson2JsonRedisSerializer);
template.afterPropertiesSet();
return template;
}
示例5: redisTemplate
import com.fasterxml.jackson.annotation.PropertyAccessor; //导入依赖的package包/类
@Bean("redisTemplate") //新家的这个注解 10-26 12:06
@SuppressWarnings({ "rawtypes", "unchecked" })
public RedisTemplate<String, String> redisTemplate(RedisConnectionFactory redisFactory){
StringRedisTemplate template = new StringRedisTemplate(redisFactory);
Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new
Jackson2JsonRedisSerializer(Object.class);
ObjectMapper om = new ObjectMapper();
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
jackson2JsonRedisSerializer.setObjectMapper(om);
template.setValueSerializer(jackson2JsonRedisSerializer);
template.afterPropertiesSet();
return template;
}
示例6: execute
import com.fasterxml.jackson.annotation.PropertyAccessor; //导入依赖的package包/类
@Override
public void execute() {
Path taxonomyDefinitionImportPath = executionParameters.getTaxonomyDefinitionImportPath();
Path taxonomyDefinitionOutputPath = executionParameters.getTaxonomyDefinitionOutputPath();
assertRequiredArgs(taxonomyDefinitionImportPath, taxonomyDefinitionOutputPath);
taxonomyMigrator.init();
TaxonomyTerm taxonomyDefinition = taxonomyMigrator.getTaxonomyDefinition();
// Write out the JSON files
try {
ObjectMapper mapper = new ObjectMapper();
mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
File dir = taxonomyDefinitionOutputPath.toFile();
dir.mkdirs();
// Prefix is so taxonomy gets imported first, before any documents
mapper.writeValue(new File(dir, "000000_" + "publication_taxonomy.json"), taxonomyDefinition);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
示例7: ApiFactory
import com.fasterxml.jackson.annotation.PropertyAccessor; //导入依赖的package包/类
public ApiFactory(String baseUrl) {
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
this.okHttpClient = new OkHttpClient.Builder().readTimeout(60, TimeUnit.SECONDS)
.connectTimeout(60, TimeUnit.SECONDS)
.cookieJar(new SimpleCookieJar())
.addInterceptor(logging)
.build();
this.retrofit = new Retrofit.Builder().baseUrl(baseUrl)
.addConverterFactory(JacksonConverterFactory.create(
new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE)
.setVisibility(PropertyAccessor.FIELD,
JsonAutoDetect.Visibility.ANY))) // 配置Json序列化的时候只使用field name,不走getter setter
.client(okHttpClient)
.build();
}
示例8: objectToString
import com.fasterxml.jackson.annotation.PropertyAccessor; //导入依赖的package包/类
public static String objectToString (final Object object) {
if (object == null) {
return null;
}
try {
final StringWriter stringWriter = new StringWriter();
final ObjectMapper objectMapper = new ObjectMapper();
objectMapper.configure(SerializationFeature.INDENT_OUTPUT, true);
objectMapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
objectMapper.writeValue(stringWriter, object);
return stringWriter.toString().replaceAll(System.getProperty("line.separator"), "");
} catch (IOException ex) {
STRINGUTIL_LOGGER.info("Sorry. had a error on during Object to String. ("+ex.toString()+")");
return null;
}
}
示例9: redisTemplate
import com.fasterxml.jackson.annotation.PropertyAccessor; //导入依赖的package包/类
@Bean
public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory connectionFactory) {
RedisTemplate<Object, Object> template = new RedisTemplate<>();
template.setConnectionFactory(connectionFactory);
//使用Jackson2JsonRedisSerializer来序列化和反序列化redis的value值
Jackson2JsonRedisSerializer serializer = new Jackson2JsonRedisSerializer(Object.class);
ObjectMapper mapper = new ObjectMapper();
mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
mapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
serializer.setObjectMapper(mapper);
template.setValueSerializer(serializer);
//使用StringRedisSerializer来序列化和反序列化redis的key值
template.setKeySerializer(new StringRedisSerializer());
template.afterPropertiesSet();
return template;
}
示例10: configureerMapper
import com.fasterxml.jackson.annotation.PropertyAccessor; //导入依赖的package包/类
private void configureerMapper() {
// Configuratie
this.disable(MapperFeature.AUTO_DETECT_CREATORS);
this.disable(MapperFeature.AUTO_DETECT_FIELDS);
this.disable(MapperFeature.AUTO_DETECT_GETTERS);
this.disable(MapperFeature.AUTO_DETECT_IS_GETTERS);
this.disable(MapperFeature.AUTO_DETECT_SETTERS);
// Default velden niet als JSON exposen (expliciet annoteren!)
setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.NONE);
this.enable(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY);
this.enable(MapperFeature.CAN_OVERRIDE_ACCESS_MODIFIERS);
// serialization
this.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
this.enable(SerializationFeature.WRITE_ENUMS_USING_INDEX);
// deserialization
this.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
}
示例11: initializeMapper
import com.fasterxml.jackson.annotation.PropertyAccessor; //导入依赖的package包/类
private static ObjectMapper initializeMapper() {
return new ObjectMapper()
.registerModule(new JavaTimeModule())
.disable(MapperFeature.AUTO_DETECT_GETTERS)
.disable(MapperFeature.AUTO_DETECT_CREATORS)
.disable(MapperFeature.AUTO_DETECT_SETTERS)
.disable(MapperFeature.AUTO_DETECT_IS_GETTERS)
.disable(MapperFeature.AUTO_DETECT_FIELDS)
.disable(MapperFeature.DEFAULT_VIEW_INCLUSION)
.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.NONE)
.enable(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY)
.enable(MapperFeature.CAN_OVERRIDE_ACCESS_MODIFIERS)
// serialization
.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS)
.enable(SerializationFeature.USE_EQUALITY_FOR_OBJECT_ID)
.setSerializationInclusion(JsonInclude.Include.NON_EMPTY)
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
// deserialization
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
.enable(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE);
}
示例12: redisCacheRedisTemplate
import com.fasterxml.jackson.annotation.PropertyAccessor; //导入依赖的package包/类
@Bean
public RedisTemplate<Object, Object> redisCacheRedisTemplate() {
RedisTemplate<Object, Object> template = new RedisTemplate<>();
template.setConnectionFactory(connectionFactory);
Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<>(Object.class);
ObjectMapper om = new ObjectMapper();
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
jackson2JsonRedisSerializer.setObjectMapper(om);
template.setKeySerializer(jackson2JsonRedisSerializer);
template.setValueSerializer(jackson2JsonRedisSerializer);
return template;
}
示例13: redisTemplate
import com.fasterxml.jackson.annotation.PropertyAccessor; //导入依赖的package包/类
@Bean
public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory factory) throws UnknownHostException {
RedisTemplate<Object, Object> template = new RedisTemplate<>();
template.setConnectionFactory(factory);
Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
ObjectMapper mapper = new ObjectMapper();
mapper.findAndRegisterModules();
mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE);
mapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
jackson2JsonRedisSerializer.setObjectMapper(mapper);
template.setValueSerializer(jackson2JsonRedisSerializer);
template.setKeySerializer(new StringRedisSerializer());
template.afterPropertiesSet();
return template;
}
示例14: initialize
import com.fasterxml.jackson.annotation.PropertyAccessor; //导入依赖的package包/类
@Override
public void initialize(Bootstrap<BitShadowConfiguration> bootstrap) {
bootstrap.addBundle(GuiceBundle.builder()
.modules(new BitShadowWebModule())
.build()
);
bootstrap.addBundle(new SwaggerBundle<BitShadowConfiguration>() {
@Override
protected SwaggerBundleConfiguration getSwaggerBundleConfiguration(BitShadowConfiguration configuration) {
return configuration.swaggerBundleConfiguration;
}
});
bootstrap.getObjectMapper()
.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false)
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE)
.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY)
.findAndRegisterModules();
}
示例15: setup
import com.fasterxml.jackson.annotation.PropertyAccessor; //导入依赖的package包/类
/**
* Register.
*/
public void setup() {
// Prepare Environment with VertxInject
Environment.create();
// Set default Json Mapper options
Json.mapper.setAnnotationIntrospector(new JacksonLombokAnnotationIntrospector())
.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY).setSerializationInclusion(JsonInclude.Include.NON_NULL)
.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS)
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
//Safe register VertxJsonModule on Mapper
.registerModule(new Jdk8Module())
.registerModule(new JavaTimeModule())
.registerModule(new ParameterNamesModule())
.registerModule(new VertxJsonModule());
}