import com.kwan.spring5.Book; import com.kwan.spring5.service.BookService; import org.junit.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; /** * jdbc添加数据 * * @author : qinyingjie * @version : 2.2.0 * @date : 2022/11/12 18:43 */ public class Spring_25_add { @Test public void test1() { ApplicationContext ctx = new ClassPathXmlApplicationContext("spring25.xml"); BookService bookService = ctx.getBean("bookService", BookService.class); Book book = new Book(); book.setUserId("1"); book.setUsername("1"); book.setUstatus("1"); bookService.add(book); } }