zoukankan      html  css  js  c++  java
  • Java框架spring Boot学习笔记(一):开始第一个项目

    新建一个项目,选择Spring initializr

    修改group和项目名

    添加依赖包Web,MongoDB

    设置保存位置和工程名

    新建一个test的文件

    输入代码:

     1 package com.xxx.test.spider;
     2 
     3 import org.springframework.stereotype.Service;
     4 
     5 import javax.annotation.PostConstruct;
     6 import java.util.Date;
     7 
     8 import static java.lang.Thread.*;
     9 
    10 //如果一个类带了@Service注解,将自动注册到Spring容器
    11 @Service
    12 public class test {
    13     //启动spring时运行这个方法
    14     @PostConstruct
    15     public void fun(){
    16         while (true){
    17             try {
    18                 Thread.sleep(1000); //每隔1秒
    19             } catch (InterruptedException e) {
    20                 e.printStackTrace();
    21             }
    22             System.out.println(new Date()); //打印当前时间
    23         }
    24     }
    25 }

    运行输出:

      .   ____          _            __ _ _
     /\ / ___'_ __ _ _(_)_ __  __ _    
    ( ( )\___ | '_ | '_| | '_ / _` |    
     \/  ___)| |_)| | | | | || (_| |  ) ) ) )
      '  |____| .__|_| |_|_| |_\__, | / / / /
     =========|_|==============|___/=/_/_/_/
     :: Spring Boot ::        (v1.5.8.RELEASE)
    
    2017-10-30 15:33:23.583  INFO 8108 --- [           main] com.xxx.test.TestApplication             : Starting TestApplication on CXYF-100-049 with PID 8108 (D:IdeaProjectsx	est	argetclasses started by jacky.jiang in D:IdeaProjectsx	est)
    2017-10-30 15:33:23.585  INFO 8108 --- [           main] com.xxx.test.TestApplication             : No active profile set, falling back to default profiles: default
    2017-10-30 15:33:23.621  INFO 8108 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@6dde5c8c: startup date [Mon Oct 30 15:33:23 CST 2017]; root of context hierarchy
    Mon Oct 30 15:33:24 CST 2017
    Mon Oct 30 15:33:25 CST 2017
    Mon Oct 30 15:33:26 CST 2017
  • 相关阅读:
    增加正则项Regularization to Prevent Overfitting
    feature_column、fc.input_layer以及各种类型的column如何转化
    input_fn如何读取数据
    matplotlib.pyplot如何绘制多张子图
    机器学习之杂乱笔记
    Adobe Flash Player
    LSTM/GRU-讲得非常细致
    anaconda python36 tensorflow virtualenv
    畅通工程-HZNU寒假集训
    食物链-HZUN寒假集训
  • 原文地址:https://www.cnblogs.com/zylq-blog/p/7754759.html
Copyright © 2011-2022 走看看