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

硅谷电视剧他们做的是网站还是软件建筑图纸字母代表大全图解

硅谷电视剧他们做的是网站还是软件,建筑图纸字母代表大全图解,奥地利网站后缀,wordpress子域名设置SpringBoot springboot也是spring公司开发的一款框架。为了简化spring项目的初始化搭建的。 特点specialty#xff1a; springboot的特点: 1#xff09; 自动配置 Spring Boot的自动配置是一个运行时#xff08;更准确地说#xff0c;是应用程序启动时#xff09;的过程 springboot的特点: 1 自动配置 Spring Boot的自动配置是一个运行时更准确地说是应用程序启动时的过程考虑了众多因素才决定Spring配置应该用哪个不该用哪个。该过程是SpringBoot自动完成的。 2 起步依赖 起步依赖本质上是一个Maven项目对象模型Project Object ModelPOM定义了对其他库的传递依赖这些东西加在一起即支持某项功能。 简单的说起步依赖就是将具备某种功能的坐标打包到一起并提供一些默认的功能。 3 辅助功能 提供了一些大型项目中常见的非功能性特性如嵌入式服务器tomcat、安全、指标健康检测、外部配置等。 创建Create 搭建springboot的项目 新建选择Spring Boot|Spring Initializr SpringBoot版本3.0以上使用java17选择Web中SpringWeb包(剩下的看需求) Java8配置------------------------------------ ?xml version1.0 encodingUTF-8? project xmlnshttp://maven.apache.org/POM/4.0.0 xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsdmodelVersion4.0.0/modelVersionparentgroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-parent/artifactId!--springboot3.0以上必须使用jdk17--version2.3.12.RELEASE/versionrelativePath/ !-- lookup parent from repository --/parentgroupIdcom.ykq/groupIdartifactIdqy174-demo01/artifactIdversion0.0.1-SNAPSHOT/versionnameqy174-demo01/namedescriptionqy174-demo01/description ​properties!--java使用版本--java.version8/java.version/propertiesdependencies!--web依赖jar--dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependency ​!--单元测试jar--dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-test/artifactIdscopetest/scope/dependency/dependencies   !--如果下方出现红色可以删除--buildpluginsplugingroupIdorg.springframework.boot/groupIdartifactIdspring-boot-maven-plugin/artifactId/plugin/plugins/build ​ /project环境|文件配置: 关于SpringBoot的配置文件和框架使用 常用的配置文件种类: springboot提供了两种配置文件。不管是哪种他们的前缀都是application 第一种application.properties 第二种:application.yml | application.yaml 如果两个文件同时存在,properties优先级更高。 #.yml | .yaml文件写入格式(:后务必跟空格然后再写入值,字符串无须) #key: # value: hhh # key2: value server:port: 8088servlet:context-path: /bbb #properties写入格式(字符串无须) #keyvalue #key.key2value server.port8080 server.servlet.context-path/aaa *包扫描的原理 ssm项目必须加包扫描。而现在springboot没有在写包扫描了。自带了包扫描的功能。核心在主类上SpringBootApplication上它是一个复合注解。里面包含: EnableAutoConfiguration开启自动配置里面包含: AutoConfigurationPackage, Import({AutoConfigurationPackages.Registrar.class}) 需要导入一个自动配置包的类。加载主类所在的包并按照该包进行扫描。 SpringBootApplication ​ ComponentScan(basePackages {com.gzx.demo1.config,com.gzx.demo1.controller}) //不写该注释默认扫描该文件所在的包,加上该注释指定扫描的包,默认扫描消失; ​ public class Demo1Application { ​public static void main(String[] args) {SpringApplication.run(Demo1Application.class, args);} ​ } 自动装配原理: 我们原来ssm项目都需要加载前端控制器DispatcherServlet. 而现在的springboot并没有加载DispatcherServlet。 springboot具备自动装配的功能。 127个自动装配 springboot启动时加载了使用SpringbootApplication注解的类该注解是一个符合注解包含EnableAutoConfiguration该注解开启了自动装配功能该注解也是一个符合注解里面包含Import({AutoConfigurationImportSelector.class})导入AutoConfigurationImportSelector该类自动装配选择器类该类会自动加载很多自动装配。每个自动装配会完成对于的自动装配功能 protected AutoConfigurationEntry getAutoConfigurationEntry(AnnotationMetadata annotationMetadata){if(!this.isEnabled(annotationMetadata)){return EMPTY_ENTRY;} eles {AnnotationAttrbutes attributes this. getAttributes(annotationMetadata);//获取所有的自动装配类ListString configurations this.getCandidateConfigurations(annotationMetadata,attrbutes);//移除重复的自动装配类configurations this.removeDuplicates(configurations); ​SetString exclusions this.getExclusions(annotationMetadata,attributes); ​this.checkExcludedClasses(configurations,exclusions);//移除排除的自动配置类configurations.removeAll(exclusions);//过滤掉没有使用的starter自动配置configurations this.getConfigurationClassFilter().filter(configurations); ​this.fireAutoConfigurationImporEvents(configurations,exclusions); ​return new AutoConfigurationEntry(configurations,exclusion);} } *读取配置文件中的内容 我们习惯把一些自己的信息放入配置文件中便于修改。比如OSS. 支付。 我们还希望通过java代码能够读取到配置文件中自己的信息。 springboot提供了两种方式用于读取springboot配置文件中信息的方式。 第一种: ConfigurationProperties 使用在类上 ConfigurationProperties(prefix前缀) #配置文件 users.namehhh users.age123 users.hobbyswim,basketball ConfigurationProperties(prefix users)//定义读取属性名 Component//该类的创建spring,而且创建时自动读取配置文件为users的属性 Data public class User {private String name;private int age;private ListString hobby; } 第二种: Value 使用在变量上 Value(${类名.变量名})(只能读取基本类型和字符串类型) RestController public class TestController {//将属性文件中变量给予注释变量Value(${users.name})private String name; ​//访问地址GetMapping(/user)public String test(){System.out.println(name);return name;} } *profile多环境配置 自理解: 通过不同的配置文件切换spring配置,再主配置文件中进行便捷切换; 我们在开发Spring Boot应用时通常同一套程序会被安装到不同环境比如开发、测试、生产等。其中数据库地址、服务器端口等等配置都不同如果每次打包时都要修改配置文件那么非常麻烦。profile功能就是来进行动态配置切换的。 profile配置文件 多profile文件方式,yml多文档方式 profile激活方式 配置文件|命令行参数 常用命名方式: application-(命名).properties [自定义的配置文件] 相同配置依然还是放在application.properties中 application-dev.properties [开发环境的配置文件] application-test.properties [测试环境的配置文件] application-pro.properties [生产环境的配置文件] 激活对应配置文件: 第一种:配置文件内 #激活对应环境的配置文件spring.profiles.active命名 spring.profiles.activedev 第二种:命令行使用 java –jar xxx.jar --spring.profiles.activedev 注册web组件|过滤器 自理解 将ssm的xml配置文件改为类中声明使用 web组件表示的就是servlet,filter组件。 创建一个Servlet public class MyServlet extends HttpServlet {Overrideprotected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {System.out.println(经过MyServlet);} } ​ public class MyFilter implements javax.servlet.Filter {Overridepublic void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {System.out.println(经过DoFilter);} } 创建一个配置类 Configuration //表示该类为配置类等价于之前的xml配置文件 public class MyConfig { ​Bean //等价于bean标签.public ServletRegistrationBean  myServlet(){ServletRegistrationBean beannew ServletRegistrationBean();bean.setServlet(new MyServlet());bean.setName(my);bean.setLoadOnStartup(1);bean.addUrlMappings(/my);return bean;} ​Beanpublic FilterRegistrationBean myFilter() {FilterRegistrationBean bean new FilterRegistrationBean();bean.setFilter(new MyFilter());bean.setName(filter);bean.addUrlPatterns(/*);return bean;} } 整合第三方框架: 整合mybatis 引入依赖 dependencies dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId /dependency !--mysql的驱动依赖 3.-- dependencygroupIdmysql/groupIdartifactIdmysql-connector-java/artifactId /dependency ​ !--mybatis和springboot整合的jar.-- dependencygroupIdorg.mybatis.spring.boot/groupIdartifactIdmybatis-spring-boot-starter/artifactIdversion3.0.3/version /dependency ​ ​ dependencygroupIdorg.projectlombok/groupIdartifactIdlombok/artifactIdoptionaltrue/optional /dependency dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-test/artifactIdscopetest/scope /dependency /dependencies ​ 配置文件 spring.application.nameqy174-springboot-mybatis ​ #数据源的信息 spring.datasource.driver-class-namecom.mysql.cj.jdbc.Driver spring.datasource.urljdbc:mysql://localhost:3306/qy174-springboot?serverTimezoneAsia/Shanghai spring.datasource.usernameroot spring.datasource.passwordroot ​ ​ #配置mybatis映射文件的路径 mybatis.mapper-locationsclasspath:mapper/*.xml 实体类 Data public class User { private Integer userid; private String username; private String sex; private Integer age; } dao public interface UserDao { int insert(User user); int delete(Integer id); int update(User user); User select(Integer id); ListUser selectAll(); } 映射文件 ?xml version1.0 encodingUTF-8? !DOCTYPE mapperPUBLIC -//mybatis.org//DTD Mapper 3.0//ENhttp://mybatis.org/dtd/mybatis-3-mapper.dtd mapper namespacecom.ykq.dao.UserDao ​ insert idinsertinsert into user(username,age,sex) values(#{username},#{age},#{sex}) /insert update idupdateupdate user set username#{username},age#{age},sex#{sex} where userid#{userid} /update delete iddeletedelete from user where userid#{id} /delete select idselectById resultTypecom.ykq.entity.Userselect * from user where userid#{id} /select select idselectAll resultTypecom.ykq.entity.Userselect * from user /select ​ /mapper service Service public class UserServiceImpl implements UserService { Autowired private UserDao userDao; Override public R selectAll() {ListUser users userDao.selectAll();return new R(200,查询成功,users); } ​ Override public R selectById(Integer id) {User user userDao.selectById(id);if(usernull){return new R(500,查询失败,null);}else{return new R(200,查询成功,user);} } ​ Override public R insert(User user) {int i userDao.insert(user);if(i0){return new R(200,添加成功,null);}return new R(500,添加失败,null); } ​ Override public R update(User user) {int update userDao.update(user);if (update0){return new R(200,修改成功,null);}return new R(500,修改失败,null); } ​ Override public R delete(Integer id) {int i userDao.delete(id);if (i0){return new R(200,删除成功,null);}return new R(500,删除失败,null); } } ​ controller RestController RequestMapping(/user) public class UserController { ​ Autowired private UserService userService; GetMapping(/list) public R list() {return userService.selectAll(); } ​ //getById/1 GetMapping(/getById) public R getById(Integer id) {return userService.selectById(id); } ​ DeleteMapping(/deleteById) public R deleteById(Integer id) {return userService.delete(id); } ​ PostMapping(/insert) public R insert(RequestBody User user) {return userService.insert(user); } ​ PutMapping(/update) public R update(RequestBody User user) {return userService.update(user); } } ​ 问题集: 没有为dao生成代理实现类 方法1: SpringBootApplication ​ //使用该注释为dao包类内的mapper类生成代理实现类 MapperScan(basePackages {com.gzx.dao}) ​ public class Demo1Application { ​public static void main(String[] args) {SpringApplication.run(Demo1Application.class, args);} ​ } 方法2: //在需要生成的mapper类代理实现类中写该注释 Mapping NoClassDefFoundError: 导包异常 java,lang.NoClassDefFoundError:org/springframework/aot/AoDetecor mybatis和springboot整合的版本太高。 DispatcherServletAutoConfiguration类: //创建Servlet注册器-[DispatchServlet以及路径] DispatcherServletRegistrationBean registration new DispatcherServletRegistrationBean(dispatcherServlet,webMvcPrpert...)
http://www.yayakq.cn/news/2844/

相关文章:

  • 杭州余杭做网站公司石家庄解封最新政策
  • 企业形象网站建设企业网页制作方面
  • 电子商务网站建设需要做好哪些准备wordpress怎么使用插件下载
  • 有什么网站可以帮人做模具吗西安关键词排名软件
  • 吉林省干部网络培训优化网站排名的方法
  • 收费的网站怎么做的vlc+WordPress
  • 在线解压rar网站贵阳优化网站建设
  • 深圳网站建设犀牛云于飞网站开发
  • 济南网站建设公司排行做购物车网站多少钱
  • 聊城房地产网站建设企业宣传网站建设需求说明书
  • 做微网站的公司哪家好武义县网站建设公司
  • 学校信息门户网站建设站长统计app下载
  • 婚纱摄影网站建设手机怎么自己做软件
  • 网站建设后应该干什么企业网站建设报价方案
  • 网站加速器下载vps怎么做多个网站
  • o2o网站系统建设网站集约化平台建设
  • 玉溪哪有网站建设开发互联网工程有限公司
  • wordpress 用ip访问seo营销是指
  • 网站历史权重查询不会写程序如何做网站
  • 怎么做报名网站wordpress 图片延迟
  • 深圳做网站龙华新科温州市网络科技有限公司
  • 如何优化网站到首页优化做网站横幅 的网站推荐几个
  • 案例网站有哪些做文案公众号策划兼职网站
  • 免费建站平台哪家好网站改版需要多少钱
  • 北京国际建设集团网站网站商城定制网站建设
  • 贵州省建设厅考证官方网站网店美工培训教程
  • 网站建设组织discuz 网站搬家
  • 更换网站需要备案吗装饰公司手机网站
  • 网站开发及建设做门户网站的公司
  • 如何高效建设品牌网站百度收录网站多久