commit 2f2741ed6aabea5b927045e4f0f4d7efd82ea9d7 Author: yangbinbin <2926488909@qq.com> Date: Thu Oct 10 10:51:10 2024 +0800 task1 diff --git a/spring/src/main/java/com/hnucm/spring/UserService.java b/spring/src/main/java/com/hnucm/spring/UserService.java new file mode 100644 index 0000000..3cf4964 --- /dev/null +++ b/spring/src/main/java/com/hnucm/spring/UserService.java @@ -0,0 +1,23 @@ +package com.hnucm.spring; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Controller; +import org.springframework.stereotype.Repository; +import org.springframework.stereotype.Service; + +// id = userService +// @Component =Service =Controller =Repository +@Service +public class UserService { + + // Autowired Spring自动注入 + setter+getter + @Autowired + private UserDao userDao; + + + // 如何调用Spring容器 finduser + public void findUser(){ + userDao.findUser(); + } +} diff --git a/spring/src/test/java/com/hnucm/spring/AppTest.java b/spring/src/test/java/com/hnucm/spring/AppTest.java new file mode 100644 index 0000000..c047147 --- /dev/null +++ b/spring/src/test/java/com/hnucm/spring/AppTest.java @@ -0,0 +1,38 @@ +package com.hnucm.spring; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +}