go to  ForumEasy.com   
JavaPro
Home » Archive » Message


[Email To Friend][View in Live Context][prev topic « prev post | next post » next topic]
  Way#1 Spring Bean by XML Configuration
 
Subject: Way#1 Spring Bean by XML Configuration
Author: WebSpider
In response to: 3 Ways to Define Spring Bean
Posted on: 10/20/2019 10:54:49 PM


The POJO class

package com.example.spring.model;

public class Name_XML_Bean {

	private String name;
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
}


The XML configuration file app-config.xml
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
    http://www.springframework.org/schema/context 
    http://www.springframework.org/schema/context/spring-context-4.0.xsd">
    
    <bean name="myXmlBean" class="com.example.spring.model.Name_XML_Bean"></bean>
	
	</beans>


 

> On 10/20/2019 10:53:45 PM WebSpider wrote:


Like Java bean, a Spring bean is just POJO class which can be instantiated by Spring IoC Container. There are three ways to define Spring bean:
  • XML configuration based bean
  • Java configuration based bean
  • Annotation based bean





    References:

  •  


     
    Powered by ForumEasy © 2002-2022, All Rights Reserved. | Privacy Policy | Terms of Use
     
    Get your own forum today. It's easy and free.