zoukankan      html  css  js  c++  java
  • spring-boot学习

        简单的介绍springboot这个微服务框架;

        程序员的第一课:写运行helloworld;

        介绍项目结构;

        如何在idea中配置热部署;

        简单的测试;

        配置pom文件下载源:在项目下右键选择maven,选择open “setting.xml”,将下面内容复制粘贴即可:

        

    <?xml version="1.0" encoding="UTF-8"?>
    <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
        <mirrors>
            <!-- mirror
             | Specifies a repository mirror site to use instead of a given repository. The repository that
             | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
             | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
             |
            <mirror>
              <id>mirrorId</id>
              <mirrorOf>repositoryId</mirrorOf>
              <name>Human Readable Name for this Mirror.</name>
              <url>http://my.repository.com/repo/path</url>
            </mirror>
             -->
    
            <mirror>
                <id>alimaven</id>
                <name>aliyun maven</name>
                <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
                <mirrorOf>central</mirrorOf>
            </mirror>
    
            <mirror>
                <id>uk</id>
                <mirrorOf>central</mirrorOf>
                <name>Human Readable Name for this Mirror.</name>
                <url>http://uk.maven.org/maven2/</url>
            </mirror>
    
            <mirror>
                <id>CN</id>
                <name>OSChina Central</name>
                <url>http://maven.oschina.net/content/groups/public/</url>
                <mirrorOf>central</mirrorOf>
            </mirror>
    
            <mirror>
                <id>nexus</id>
                <name>internal nexus repository</name>
                <!-- <url>http://192.168.1.100:8081/nexus/content/groups/public/</url>-->
                <url>http://repo.maven.apache.org/maven2</url>
                <mirrorOf>central</mirrorOf>
            </mirror>
    
        </mirrors>
    </settings>
    •  快速体验web开发(domain和web的使用):第3课

        对json的友好支持;

        请求传参;

        数据校验;

        自定义的Filter;

        自定义的Property;

        遇到的问题:单元测试中如果出现如下错误,则表示测试文件与main文件的目录不对应。

    java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=...) with your test
    
        at org.springframework.util.Assert.state(Assert.java:70)
        at org.springframework.boot.test.context.SpringBootTestContextBootstrapper.getOrFindConfigurationClasses(SpringBootTestContextBootstrapper.java:202)
        at org.springframework.boot.test.context.SpringBootTestContextBootstrapper.processMergedContextConfiguration(SpringBootTestContextBootstrapper.java:137)
        at org.springframework.test.context.support.AbstractTestContextBootstrapper.buildMergedContextConfiguration(AbstractTestContextBootstrapper.java:397)
        at org.springframework.test.context.support.AbstractTestContextBootstrapper.buildDefaultMergedContextConfiguration(AbstractTestContextBootstrapper.java:311)
        at org.springframework.test.context.support.AbstractTestContextBootstrapper.buildMergedContextConfiguration(AbstractTestContextBootstrapper.java:265)
        at org.springframework.test.context.support.AbstractTestContextBootstrapper.buildTestContext(AbstractTestContextBootstrapper.java:105)
        at org.springframework.boot.test.context.SpringBootTestContextBootstrapper.buildTestContext(SpringBootTestContextBootstrapper.java:82)
        at org.springframework.test.context.TestContextManager.<init>(TestContextManager.java:120)
        at org.springframework.test.context.TestContextManager.<init>(TestContextManager.java:105)
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTestContextManager(SpringJUnit4ClassRunner.java:152)
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.<init>(SpringJUnit4ClassRunner.java:143)
        at org.springframework.test.context.junit4.SpringRunner.<init>(SpringRunner.java:49)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
        at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
        at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
        at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
        at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
        at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
        at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:49)
        at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
        at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
        at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

        解决方案:在写单元测试时,测试的文件与main文件目录相同,如下:

        

    •  Spring Data JPA的使用(repository的使用):第4课

        上手JPA;

        单表JPA中连接数据库的操作;

        多表JPA中连接数据库的操作;

        遇到的问题:

        

    • 模板引擎Thymeleaf(resources的使用):第5课

        利用该模板写前端代码;

    • JPA和Themeleaf的实践:第6课

        遇到的问题:

          1. Thymeleaf中红色波浪线的问题

          2. Spring Boot 1.0 升级到 2.0的变化/升级后的采坑记录

          3.Spring Boot Thymeleaf 报错:Whitelabel Error Page

          4.mysql报SSL的错误

          5.Themeleaf使用详解

          

  • 相关阅读:
    浏览器为何禁止跨域(同源策略)
    viewPager
    How to remove focus without setting focus to another control?
    android ANR
    解决Ubuntu系统中文乱码显示问题
    USB 3.0规范中译本 第6章 物理层
    库&框架-----CDN网络引用总结
    18_如何排错
    17_今日回顾
    16_sql注入的原理及处理
  • 原文地址:https://www.cnblogs.com/yunkaiL/p/10329371.html
Copyright © 2011-2022 走看看