[Spring] spring environment to build, STS tools

 

  • Way to manually download the jar package

Download spring in the maven jar package, the address is: http://maven.springframework.org/release/org/springframework/spring/

You can download various versions of the spring jar package.

4.3.9 In an example, the compressed download dist

The core jar package after decompression need to use, there are

spring-aop.jar (JAR required the development of AOP), ... beans (jar of treated Bean), ... context (jar spring process context), ... core (spring core jar), .. .expersion (spring expression)

Also need third-logging.jar Commons   https://mvnrepository.com/artifact/commons-logging/commons-logging/1.1.1

 

Require automatic when prompted, you need to install the plug-sts spring

Address https://spring.io/tools/sts/all download the corresponding version

Or directly using the official sts tool https://spring.io/tools/sts

  • Write configuration file

After installing sts, create a bean configuration named in the project called applicationContext.xml

 Xml file can be configured bean

In Test Examples Bean Student class (three attributes stuName, stuAge, stuNo)

xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
    <bean id="student" class="com.beans.Student">
        <property name="stuNo" value="2"></property>
        <property name="stuName" value="ls"></property>
        <property name="stuAge" value="20"></property>
    </bean>

</beans>

Test categories:

package com.test;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.beans.Student;

public class Test {
    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        Student student = (Student) context.getBean("student");
        System.out.println(student);
    }
}

 

Guess you like

Origin www.cnblogs.com/to-red/p/11231090.html