MyEclipse2017 method for creating a Spring Project,
MyEclipse2017 creates a Spring Project for your reference. The specific content is as follows:
1. Create a Web Project
2. Right-click the project --> Properties
3. Search for Spring --> Peoject Facets --> Find Spring on the right side, tick and save
4. Test
4.1 create classes
Package cn. spring. user;/*** @ author Dzsom * @ date March 13, 2018 11:42:03 * @ encoding UTF-8 * @ version 1.0 **/public class User {private String uname; private int age; public String getUname () {return uname;} public void setUname (String uname) {this. uname = uname;} public int getAge () {return age;} public void setAge (int age) {this. age = age ;}}
4.2 modify the configuration file applicationContext. xml under src.
<? Xml version = "1.0" encoding = "UTF-8"?> <Beans xmlns = "http://www.springframework.org/schema/beans" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns: p = "http://www.springframework.org/schema/p" xsi: schemaLocation = "http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd"> <! -- Submit the object to Spring Management --> <bean name = "user" class = "cn. spring. user. User"> </bean> </beans>
4.3 create a Test class (@ Test needs to import the junit package)
Package cn. spring. test; import org. junit. test; import org. springframework. context. applicationContext; import org. springframework. context. support. classPathXmlApplicationContext; import cn. spring. user. user;/*** @ author Dzsom * @ date March 14, 2018 9:35:19 * @ encoding UTF-8 * @ version 1.0 **/public class Demo {@ Test public void fun () {// 1. create the container object ApplicationContext ac = new ClassPathXmlApplicationContext ("applicationContext. xml "); // 2. to the container, the object User = (user) ac. getBean ("user"); // 3. print System. out. println (user );}}
4.4 right-click to run the test. If there is a value output, Spring is set up successfully.
The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.