Spring Bean 枚举属性注入

1、名称空间配置

1<beans xmlns="http://www.springframework.org/schema/beans" 2       xmlns:util="http://www.springframework.org/schema/util" 3       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd 4                           http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd">

2、JAVA

1package com.demo.bean; 2 3class TestBean { 4 5    private Gender gender 6 7    public void setGender(Gender gender){ 8        this.gender = gender; 9    } 10 11    public Gender getGender(){ 12        return gender; 13    } 14 15} 16 17package com.demo.utils; 18 19public enum Gender { 20    MALE, FEMALE, UNSPECIFIED 21}

3、Bean 配置

1<bean id="testBean" class="com.demo.bean.TestBean"> 2    <property name="gender" ref="gender" /> 3</bean> 4<util:constant id="gender" static-field="com.demo.utils.MALE" />
点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

MySQL部分从库上面因为大量的临时表tmp_table造成慢查询

背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

ssm框架整合

applicationContext.xml<beansxmlns"http://www.springframework.org/schema/beans"xmlns:context"http://www.springframework.org/schema/context"xmlns:p"http://www.springframew

spring集成JMS activeMQ 头文件

<beansxmlns"http://www.springframework.org/schema/beans"xmlns:xsi"http://www.w3.org/2001/XMLSchemainstance"xmlns:amq"http://activemq.apache.org/schema/core"