# springstudy **Repository Path**: isspark/springstudy ## Basic Information - **Project Name**: springstudy - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-03-22 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Spring 项目学习 ---------- ## Javaweb集成Spring框架 - ### 1.修改web.xml org.springframework.web.context.ContextLoaderListener contextConfigLocation classpath:applicationContext.xml - ### 2.创建applicationContent.xml - ### 3.测试 - **3.1 创建TestDI.java** @Component public class TestDI { //注入配置中的值 @Value("${jdbc.driver}") private String testproperteis; private static final Logger logger = LogManager.getLogger(TestDI.class); public TestDI() { System.out.println(">>>>>>>>> enter TestDI class constructor"); } public int add(int a ,int b){ return a+b; } public void testMethod(){ System.out.println(this.testproperteis); } } - **3.2 创建测试类** /** * 将所需加载的xml文件指定为locations的value。如:@ContextConfiguration(locations = { "classpath:Application-Redis.xml" }) */ @ContextConfiguration(locations = {"classpath:applicationContext.xml"}) @RunWith(SpringJUnit4ClassRunner.class) public class SpringTestBase extends AbstractJUnit4SpringContextTests { } public class TestDITest extends SpringTestBase { @Autowired private TestDI testDI; @Test public void TestAdd(){ Assert.assertEquals(4,testDI.add(1,2)); } @Test public void TestAdd2(){ Assert.assertEquals(3,testDI.add(1,2)); } @Test public void testMethod(){ System.out.println(""); testDI.testMethod(); } } - **3.3 创建配置文件db.properties** jdbc.driver=com.mysql.jdbc.Driver jdbc.url=jdbc:mysql://127.0.0.1:3306/springstudy?characterEncoding=utf-8 jdbc.username=root jdbc.password=shouwang13 ## 整合SpringMVC - ### 1.修改web.xml,增加以下内容 springmvc org.springframework.web.servlet.DispatcherServlet contextConfigLocation classpath:springmvc.xml 1 springmvc / - ### 2.创建springmvc.xml    ### 整合SpringTest* ### 整合SpringJDBC* ### 整合Mybatis* ### 整合Hibernate* #### 整合tk.mybatis* ### 整合swagger* ### 整合Spring Batch* ### quartz *和 spring task * ### mail 发送 * ### 整合Spring Security/Apache Shiro ### 整合Spring Session