当前位置: 首页 > news >正文

wordpress主题出错修改主题抖音seo

wordpress主题出错修改主题,抖音seo,wordpress上传视频,查看网站开发文章目录 准备数据pom.xml文件中引用需要的库准备好dao层接口和service层接口和实现类准备好 jdbc.properties 和 user.properties编写Druid的jdbcConfig配置类编写spring的配置类SpringConfig编写Dao层的实现类的逻辑测试类参考文献 准备数据 create database if not exists … 文章目录 准备数据pom.xml文件中引用需要的库准备好dao层接口和service层接口和实现类准备好 jdbc.properties 和 user.properties编写Druid的jdbcConfig配置类编写spring的配置类SpringConfig编写Dao层的实现类的逻辑测试类参考文献 准备数据 create database if not exists db_spring; use db_spring; drop table if exists tb_user; create table if not exists tb_user (id int primary key auto_increment,name varchar(10) not null unique,age int,id_card varchar(10) );insert into tb_user(name, age, id_card)values (张三, 23, 10001),(李四, 18, 10002),(王五, 34, 10003),(赵六, 45, 10004);select * from tb_user;pom.xml文件中引用需要的库 dependenciesdependencygroupIdorg.springframework/groupIdartifactIdspring-context/artifactIdversion6.0.12/version/dependencydependencygroupIdcom.alibaba/groupIdartifactIddruid/artifactIdversion1.1.10/version/dependencydependencygroupIdcom.mysql/groupIdartifactIdmysql-connector-j/artifactIdversion8.0.33/version/dependency /dependencies准备好dao层接口和service层接口和实现类 dao层// 接口 package com.test.dao;public interface UserDao {void selectAll();void selectById(); }service层// 接口 package com.test.service;public interface UserService {void selectAll();void selectById(); }// 实现类 package com.test.service.impl;import com.test.dao.UserDao; import com.test.service.UserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service;/*** Service注解就是标识这个类是service层的bean,spring启动的时候就会把它放入到Ioc容器中* 跟这个相似还有 Repository 和 Controller*/ Service public class UserServiceImpl implements UserService {// Autowired注解是自动装配Autowiredprivate UserDao userDao;Overridepublic void selectAll() {userDao.selectAll();}Overridepublic void selectById() {userDao.selectById();} }准备好 jdbc.properties 和 user.properties 这里分开写是为了练习加载多个配置文件所以需要再resources资源文件中新建这两个配置文件 jdbc.propertiesjdbc.drivercom.mysql.cj.jdbc.Driver jdbc.urljdbc:mysql:///db_spring?useServerPrepStmtstrue jdbc.usernameroot jdbc.passwordroot1234user.propertiesname张三 age23 sex男 idCard10001 id2编写Druid的jdbcConfig配置类 public class JdbcConfig {/*** 这里通过Value注解从properties配置文件中读取数据* 这里的前提就是在 SpringConfig这个配置类中* 通过PropertySource注解引用的资源文件中的配置文件*/Value(${jdbc.driver})private String driver;Value(${jdbc.url})private String url;Value(${jdbc.username})private String username;Value(${jdbc.password})private String password;/*** 通过 注解Bean来加载第三方*/Beanpublic DataSource dataSource() {DruidDataSource ds new DruidDataSource();ds.setDriverClassName(driver);ds.setUrl(url);ds.setUsername(username);ds.setPassword(password);return ds;} }编写spring的配置类SpringConfig package com.test.config;import org.springframework.context.annotation.*;/*** Configuration注解设置当前类为配置类* ComponentScan注解用于扫描指定路径重点bean对象* PropertySource注解用于把指定的配置文件加载借来* Import注解是用于导入三方的bean类进入Ioc容器*/ Configuration ComponentScan({com.test.dao, com.test.service}) PropertySource({classpath:user.properties, classpath:jdbc.properties}) Import(JdbcConfig.class) public class SpringConfig { }编写Dao层的实现类的逻辑 // Repository表示是dao层的bean Repository(userDao) public class UserDaoImpl implements UserDao {// 自动装配Autowiredprivate DataSource dataSource;// 获取配置文件中的数据Value(${id})private int id;Overridepublic void selectAll() {try {// 操作数据库Connection connection dataSource.getConnection();String sql select * from tb_user;PreparedStatement prepareStatement connection.prepareStatement(sql);ResultSet resultSet prepareStatement.executeQuery();while (resultSet.next()) {int id resultSet.getInt(id);String name resultSet.getString(name);String idCard resultSet.getString(id_card);int age resultSet.getInt(age);System.out.println(id: id , name: name , age: age , idCard: idCard);}// 释放资源resultSet.close();prepareStatement.close();connection.close();} catch (Exception e) {e.printStackTrace();}}Overridepublic void selectById() {try {Connection connection dataSource.getConnection();String sql select * from tb_user where id ?;PreparedStatement prepareStatement connection.prepareStatement(sql);prepareStatement.setInt(1, id);ResultSet resultSet prepareStatement.executeQuery();while (resultSet.next()) {int id resultSet.getInt(id);String name resultSet.getString(name);String idCard resultSet.getString(id_card);int age resultSet.getInt(age);System.out.println(id: id , name: name , age: age , idCard: idCard);}// 释放资源resultSet.close();prepareStatement.close();connection.close();} catch (Exception e) {e.printStackTrace();}} }测试类 public class Main {public static void main(String[] args) {/*** 获取Ioc容器* 这里是通过SpringConfig这个配置类来获取*/ApplicationContext ctx new AnnotationConfigApplicationContext(SpringConfig.class);// 获取beanUserService userService ctx.getBean(UserService.class);userService.selectAll();System.out.println( selectById );userService.selectById();} }参考文献 1. 黑马程序员SSM框架教程
http://www.eeditor.cn/news/122630/

相关文章:

  • 做淘宝客需要建网站吗涪城移动网站建设
  • 南阳卧龙区高端网站建设价格wordpress网址
  • supercell账号注册网站中国菲律宾汇率换算
  • 大连模板网站制作公司长沙市做网站公司
  • 电脑做微信推送的网站建一个网站需要什么流程
  • 内蒙古知名网站建设另一更新正在进行 wordpress
  • 红色礼品网站模板北京网站建站推广
  • 大连网站建设工作室广东中南建设有限公司网站
  • 便捷网站建设报价免费自助建站哪个网站最好
  • 网站建设合同属于什么类别做网站需要下什么软件
  • 公司推广做哪个网站楚雄市住房和城乡建设局门户网站
  • 企业网站设计注意邢台建设企业网站价格
  • 昆明企业建网站多少钱如何做网站服务器映射
  • 做网站的公司现在还赚钱吗wordpress 商城模版
  • 企业官方网站是什么南京网站推广排名前十
  • 做网站怎么看效果重庆在线开放平台
  • 查建设工程规划许可证在哪个网站大河网
  • 郑州网站设计哪家公司好php开源网站管理系统
  • 网站开发工程师考试企业网络设计方案预算
  • 电子购物网站设计网站主页的布局方式
  • 果女做拍的视频网站百度关键词首页排名服务
  • 网站快照没了阿里云新增网站
  • 市场部职能中的网站建设做付费推广哪个网站好
  • wordpress相关的网站wordpress专用主机
  • 7万字短篇小说哪家网站做的好网站备案 seo
  • 网站开发语音网站备案到
  • 做公司网站的推广工作怎样wordpress the7 建站
  • 简单的招聘网站怎么做开网站需要投资多少钱
  • 别人用我公司权限做网站WordPress插件api调用
  • 网站建设常用工具火车头 wordpress