Java Series Spring Learning--spring build (I.)

Source: Internet
Author: User
Tags aop

First, the new MAVEN project

Second, the introduction of Spring jar Package
<project xmlns= "" xmlns:xsi= "Http://" xsi: schemalocation= "" > <modelversion  >4.0.0</modelVersion> <groupId>wjxiaoqiao</groupId> <artifactId>wj</artifactId> <packaging>war</packaging> <version>0.0.1-SNAPSHOT</version> &LT;NAME&GT;WJ Maven Webapp </name> <url></url> <dependencies> <!--https://><dependency> <groupId> Org.springframework</groupid> <artifactId>spring-context</artifactId> <version>5.0.2. Release</version></dependency> <!-- Javax.servlet-api--><dependency> <groupId>javax.servlet</groupId> <artifactId> javax.seRvlet-api</artifactid> <version>4.0.0</version> <scope>provided</scope></ dependency> <dependency> <groupId>junit</groupId> <artifactid>junit</artifact id> <version>3.8.1</version> <scope>test</scope> </dependency> </depende ncies> <build> <finalName>wj</finalName> </build></project>
Third, write the configuration file
<?xml version= "1.0" encoding= "UTF-8"? ><beans xmlns= "Http://"    Xmlns:xsi= "Http://" xmlns:context= " Context "    xsi:schemalocation=" Http://       http       Http://        http:/ /        http ://        HTTP://WWW.SPRINGFRAMEWORK.ORG/SCHEMA/AOP        Http://       ">       <bean id=" test01 "class=" test.test01 "/> </beans>
Iv. Test class
Package Test;public class Test01 {public test01 () {System.out.println ("test01");} public void Prints () {System.out.println ("prints");}}
Package Test;import;import;import javax.servlet.servletexception;import Javax.servlet.http.httpservlet;import Javax.servlet.http.httpservletrequest;import Javax.servlet.http.httpservletresponse;import Org.springframework.context.applicationcontext;import;public class Aservlet extends HttpServlet { public void doget (HttpServletRequest request, httpservletresponse response) throws Servletexception, IOException { ApplicationContext context=new classpathxmlapplicationcontext ("Applicationcontext.xml"); test01 test01= (test01) Context.getbean ("test01"); Test01.prints ();}}
Five, the test is successful

Java Series Spring Learning--spring Build (i)

Related Article

Contact Us

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: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.