spring boot随便记

这是一篇随手记录,不要太关心逻辑。
新建了一个Spring Boot工程,发现多了这个东西。
spring boot随便记_第1张图片
忘了配置mysql,启动报错,百度一下,结果没有官网。
spring boot随便记_第2张图片
上Google,第一条就是官网。真是神百度。
spring boot随便记_第3张图片
加上下面几句,mysql配置Ok。

spring.datasource.url=jdbc:mysql://localhost:3306/demo
spring.datasource.username=root
spring.datasource.password=root

启动后,访问localhost:8080,还是有问题


  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.1.0.RELEASE)

2018-11-28 09:48:44.999  INFO 10956 --- [  restartedMain] com.example.demo.DemoApplication         : Starting DemoApplication on DESKTOP-I5EFT4D with PID 10956 (D:\src\demo-for-spring-boot\out\production\classes started by pikachu in D:\src\demo-for-spring-boot)
2018-11-28 09:48:45.004  INFO 10956 --- [  restartedMain] com.example.demo.DemoApplication         : No active profile set, falling back to default profiles: default
2018-11-28 09:48:45.073  INFO 10956 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2018-11-28 09:48:45.074  INFO 10956 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2018-11-28 09:48:46.286  WARN 10956 --- [  restartedMain] o.m.s.mapper.ClassPathMapperScanner      : No MyBatis mapper was found in '[com.example.demo]' package. Please check your configuration.
2018-11-28 09:48:47.411  INFO 10956 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2018-11-28 09:48:47.426  INFO 10956 --- [  restartedMain] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2018-11-28 09:48:47.426  INFO 10956 --- [  restartedMain] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/9.0.12
2018-11-28 09:48:47.432  INFO 10956 --- [  restartedMain] o.a.catalina.core.AprLifecycleListener   : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [D:\Program Files\Java\jdk1.8.0_171\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;D:\Users\pikachu\AppData\Local\Programs\Python\Python37\Scripts\;D:\Users\pikachu\AppData\Local\Programs\Python\Python37\;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;D:\dev\Git\cmd;D:\dev\CMake\bin;D:\dev\PuTTY\;D:\dev\WinSCP\;D:\dev\apache-ant-1.10.1\bin;D:\dev\db-derby-10.13.1.1-bin\bin;D:\dev\glassfish5\bin;C:\Program Files\Java\jdk1.8.0_171\bin;C:\Program Files\Java\jdk1.8.0_171\jre\bin;D:\dev\Java\jre1.8.0_144\bin;C:\Program Files\dotnet\;D:\dev\Android\SDK\platform-tools;C:\Program Files (x86)\Pandoc\;D:\dev\Qt\Qt5.9.2\5.9.2\mingw53_32\bin;D:\Program Files\MongoDB\Server\3.4\bin;D:\program\aspectj1.9\bin;D:\Program Files\nodejs\;D:\Program Files (x86)\Yarn\bin\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Users\pikachu\AppData\Local\Microsoft\WindowsApps;C:\Users\pikachu\AppData\Local\atom\bin;d:\texlive\2017\bin\win32;C:\Users\pikachu\AppData\Roaming\npm;C:\Users\pikachu\AppData\Local\Yarn\bin;%USERPROFILE%\AppData\Local\Microsoft\WindowsApps;;.]
2018-11-28 09:48:47.574  INFO 10956 --- [  restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2018-11-28 09:48:47.574  INFO 10956 --- [  restartedMain] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 2497 ms
2018-11-28 09:48:47.598  INFO 10956 --- [  restartedMain] o.s.b.w.servlet.ServletRegistrationBean  : Servlet dispatcherServlet mapped to [/]
2018-11-28 09:48:47.602  INFO 10956 --- [  restartedMain] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-11-28 09:48:47.603  INFO 10956 --- [  restartedMain] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-11-28 09:48:47.603  INFO 10956 --- [  restartedMain] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'formContentFilter' to: [/*]
2018-11-28 09:48:47.603  INFO 10956 --- [  restartedMain] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2018-11-28 09:48:47.887  INFO 10956 --- [  restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2018-11-28 09:48:48.195  INFO 10956 --- [  restartedMain] o.s.b.d.a.OptionalLiveReloadServer       : LiveReload server is running on port 35729
2018-11-28 09:48:48.358  INFO 10956 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2018-11-28 09:48:48.361  INFO 10956 --- [  restartedMain] com.example.demo.DemoApplication         : Started DemoApplication in 3.892 seconds (JVM running for 5.855)
2018-11-28 09:49:37.544  INFO 10956 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2018-11-28 09:49:37.544  INFO 10956 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2018-11-28 09:49:37.553  INFO 10956 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 9 ms

spring boot随便记_第4张图片
简单加一个Controller

@RestController
public class MainController {
    @GetMapping("/")
    public static String index() {
        return "Hello, Spring Boot";
    }
}

刷新网页,居然没反应,可恶,居然没有热重载。
我有安装devtool呀
spring boot随便记_第5张图片
上Google,不敢用百度,Google没结果再回百度,这种事情,谁说得好呢?
按照这篇文章(Intellij IDEA 使用Spring-boot-devTools无效解决办法)所说的配置好,重启后,发现自动帮我启动了Spring Boot。然后又试着加了一个路由,按保存,过了一会儿,的确自动重启了,能访问新加的路由了。

2018-11-28 10:01:07.972  INFO 1476 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2018-11-28 10:01:07.973  INFO 1476 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2018-11-28 10:01:07.980  INFO 1476 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 7 ms
2018-11-28 10:02:11.740  INFO 1476 --- [      Thread-29] o.s.s.concurrent.ThreadPoolTaskExecutor  : Shutting down ExecutorService 'applicationTaskExecutor'

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.1.0.RELEASE)

2018-11-28 10:02:12.866  INFO 1476 --- [  restartedMain] com.example.demo.DemoApplication         : Starting DemoApplication on DESKTOP-I5EFT4D with PID 1476 (D:\src\demo-for-spring-boot\out\production\classes started by pikachu in D:\src\demo-for-spring-boot)
2018-11-28 10:02:12.867  INFO 1476 --- [  restartedMain] com.example.demo.DemoApplication         : No active profile set, falling back to default profiles: default
2018-11-28 10:02:13.304  WARN 1476 --- [  restartedMain] o.m.s.mapper.ClassPathMapperScanner      : No MyBatis mapper was found in '[com.example.demo]' package. Please check your configuration.
2018-11-28 10:02:13.595  INFO 1476 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2018-11-28 10:02:13.596  INFO 1476 --- [  restartedMain] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2018-11-28 10:02:13.596  INFO 1476 --- [  restartedMain] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/9.0.12
2018-11-28 10:02:13.680  INFO 1476 --- [  restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2018-11-28 10:02:13.681  INFO 1476 --- [  restartedMain] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 811 ms
2018-11-28 10:02:13.692  INFO 1476 --- [  restartedMain] o.s.b.w.servlet.ServletRegistrationBean  : Servlet dispatcherServlet mapped to [/]
2018-11-28 10:02:13.693  INFO 1476 --- [  restartedMain] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-11-28 10:02:13.693  INFO 1476 --- [  restartedMain] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-11-28 10:02:13.693  INFO 1476 --- [  restartedMain] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'formContentFilter' to: [/*]
2018-11-28 10:02:13.693  INFO 1476 --- [  restartedMain] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2018-11-28 10:02:13.777  INFO 1476 --- [  restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2018-11-28 10:02:13.962  INFO 1476 --- [  restartedMain] o.s.b.d.a.OptionalLiveReloadServer       : LiveReload server is running on port 35729
2018-11-28 10:02:13.993  INFO 1476 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2018-11-28 10:02:13.994  INFO 1476 --- [  restartedMain] com.example.demo.DemoApplication         : Started DemoApplication in 1.172 seconds (JVM running for 153.142)
2018-11-28 10:02:13.998  INFO 1476 --- [  restartedMain] .ConditionEvaluationDeltaLoggingListener : Condition evaluation unchanged
2018-11-28 10:02:25.354  INFO 1476 --- [nio-8080-exec-3] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2018-11-28 10:02:25.355  INFO 1476 --- [nio-8080-exec-3] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2018-11-28 10:02:25.361  INFO 1476 --- [nio-8080-exec-3] o.s.web.servlet.DispatcherServlet        : Completed initialization in 6 ms

发现IDEA一个新东西,一点就报错。
在这里插入图片描述
接下来做数据库了,可我没有数据库数据。
想起老早以前学习的jpetstore-6,那就把数据库抄过来吧。
spring boot随便记_第6张图片
创建表的sql: jpetstore-hsqldb-schema.sql
吐槽一下CSDN的编辑器,差点误事
spring boot随便记_第7张图片
有了数据库表后,应该根据数据库表,方向生成类。
这里做了好久,没出什么结果,百度一下,抄点什么东西过来,?。
generatorConfig.xml文件需要用mysql驱动,everything搜一下
spring boot随便记_第8张图片
反向生成时报错

Exception in thread "main" java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.

使用下面这个连接串Ok

jdbc:mysql://localhost:3306/demo?serverTimezone=UTC

生成出来的方法有点少,而且没有继承mapper通用接口

public interface AccountMapper {
    int insert(Account record);

    int insertSelective(Account record);
}

从数据库生成java类做了好久才做出来
最后用到的配置
生成配置文件




    
    


    
        
            
            
        

        
        
        

        
            
        
        
        
            
            
        
        
        
            
        
        
        
            
        
        

        
        

java类

在这里插入代码片

Spring boot devtool使用
spring boot随便记_第9张图片
Ctrl + Alt + Shift + /
spring boot随便记_第10张图片
使用问题
aop需要自己重启
增加bean需用手动重启

你可能感兴趣的:(spring boot随便记)