From 2f2741ed6aabea5b927045e4f0f4d7efd82ea9d7 Mon Sep 17 00:00:00 2001 From: yangbinbin <2926488909@qq.com> Date: Thu, 10 Oct 2024 10:51:10 +0800 Subject: [PATCH] task1 --- .../java/com/hnucm/spring/UserService.java | 23 +++++++++++ .../test/java/com/hnucm/spring/AppTest.java | 38 +++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 spring/src/main/java/com/hnucm/spring/UserService.java create mode 100644 spring/src/test/java/com/hnucm/spring/AppTest.java 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 ); + } +}