Read about spring configuration file example, The latest news, videos, and discussion topics about spring configuration file example from alibabacloud.com
applicationcontext.xml file
1, on the class, implement the Bean declaration using the following annotations
@Component refers to components, we can use this annotation to annotate when components are not properly categorized.
@Service used to label business layer components
@Controller used to Label control layer components (such as action in Controller,struts of srping MVC)
@Repository used to annotate the data Access component, the DAO compone
One: Configuration file consolidation ssh1. Create a mapping file for Hibernate entity classes, typically placed under the resource folder"-//hibernate/hibernate Mapping DTD 3.0//en""Http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >Configuration of the 2.struts.xml file
(1) Problem: A program developed locally using Spring-boot has always wanted files to be exported to a folder by day. But has been successful.Resolution process:Think of the log first to configure the Log4j.properties file, but has not been successful, I put the file in the source directory. does not take effect.Then check the data to understand that the
Spring may involve injection of complex type attributes in the configuration file when consolidating other frameworks, as illustrated below:1. Array type2.List collection type3.Set collection type4.Map collection type5.Properties Property TypeDirectly on the code:Entity class: Collectionbean.java PackageCom.imooc.ioc.demo5;ImportJava.util.*;/***
contextloaderlistener:spring MVC is the startup class in the Web container that is responsible for the initialization of the Spring IOC container in the web context, enabling the container to automatically assemble the configuration information for the ApplicationContext.Configure the class in Web. xml: Listener > Listener-class > listener-class>listener> How to deploy the ApplicationContext XML
1. Use XmlBeanFactory to read the spring configuration file:
Resource resource=new ClassPathResource("conf/spring/applicationContext.xml"); BeanFactory factory=new XmlBeanFactory(resource); com.geostar.query.beans.DataSource ds=(com.geostar.query.beans.DataSource)factory.getBean("ds");System.out.println(ds.getDriver
Spring Config file errorReferenced file contains errors (http://www.springframework.org/schema/beans/spring-beans-4.3.xsd). For more information, right click on the message in the problems View and select "Show Details ..."Projects built in MyEclipse, copied in, there is no error in eclipse, but there is a red fork in
1,classpath:applicationcontext.xml Change to Classpath*:applicationcontext.xmlThis is the same thing. Effect: Classpath*:/applicationcontext.xml2, refer to other configuration files in Applicationcontext.xml:If you write this in the same jar package,Java code
1
importresource="classpath:/applicationContext-action.xml"/>
To import the configuration files from other jar package
Spring Boot Resource file property configurationThe configuration file refers to the resources root directory application.properties or the application.yml configuration file, read the two con
Learn extjs5 with me (join 27--server web,spring,hibernate configuration file)
when we created the project earlier, it was a Java Web project, and now we need to join the Spring,hibernate,sqlserver connected jar package and join the configuration
The configuration file differs greatly from the way annotations are, with many more configuration items.
Beans2.xml
Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" xmlns:context= "Http://www.springframework.org/schema/context"xmlns:aop= "HTTP://WWW.SPRINGFRAMEWORK.ORG/SCHEMA/AOP"Xsi:schemalocation= "Http://www.springframework.org/schema/beansHttp://w
; Property> Propertyname= "UserName"value= "Zhang San Feng"> Property> Propertyname= "Userage"value= "Male"> Property> Bean>Beans> PackageJava_spring.a_main;ImportOrg.springframework.context.ApplicationContext;ImportOrg.springframework.context.support.ClassPathXmlApplicationContext;ImportJava_spring.modle.Person; Public classTestone { Public Static voidMain (string[] args) {//Gets the IOC container object for spring, which is the pa
Spring injects attributes according to the XML configuration file p namespace, springxml
The class code for generating objects and injecting attributes through namespaces is as follows:
package com.swift;public class User { private String userName; public void setUserName(String userName) { this.userName = userName; } public String fun() {
Timetoliveseconds properties; The default value is False timetoidleseconds: Sets the maximum amount of time the object is idle, in seconds, when the object expires. When an object expires, Ehcache clears it from the cache. If this value is 0, the object can be idle indefinitely. Timetoliveseconds: Sets the object to live for the longest time, over this time, the object expires. If this value is 0, the object can exist indefinitely in the cache. The property value must be g
First is a user class: Package spring_introduction;public class User {String name;Public String GetName () {return name;}public void SetName (String name) {THIS.name = name;}public void Hello () {System.out.println ("Hello" +name);}The configuration file Name.propertiesname=lucy below is the Helloname Output class: Package spring_introduction;Import java.io.IOException;Import java.util.Properties;Import Sun
SSH configuration More, there are many places have been very vague, this time to tidy up ideas.All source files are at the end of the text.XML file: Link: Https://pan.baidu.com/s/1kUHjhAJ Password: b4b3Image Ultra-clear version: Link: https://pan.baidu.com/s/1nvdzMfn Password: z8myXmind Original format: Link: Https://pan.baidu.com/s/1jH7HE1C Password: F4BBMaven + Struts2 +
Spring boot further encapsulates the original configuration of spring, making the program apes a lot easier, really thanks to the spring bootIn everyday code, the read profile properties are often encountered in the business logic of their own writing, and spring boot provid
In spring boot, a few simple steps to read the various types of property values in the configuration file (APPLICATION.YML):1, the introduction of dependency:[HTML]View PlainCopy
dependency>
groupId>org.springframework.bootgroupId>
artifactid>spring-boot-configurat
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.