Giter Site home page Giter Site logo

itrace-with-dubbo's Introduction

2017 IT Race with Dubbo Startup

基于 [spring-boot-starter-dubbo](https://github.com/teaey/spring-boot-starter-dubbo) 准备的 Dubbo 开发框架。

初始化 IDE 配置

$ mvn eclipse:eclipse  # or
$ mvn idea:idea

调试和运行

工程采用了Spring Boot 搭建。使运行这个工程变得非常简单。

$ cd itrace_startup
$ mvn spring-boot:run

工程打包

Spring Boot 工程集成了快速打包工程的方式。

$ cd itrace_startup
$ mvn package

打包完成后生成 ./tartget/itrace_startup-0.0.1-SNAPSHOT.jar 文件。

部署和运行

搭建web 工程,一般需要web容器来运行(tomcat、jetty等)。采用Spring Boot 方式,工程里面自动集成了内嵌的 web 容器,因此不需要先部署tomcat、weblogic等来运行服务。

$ java -jar itrace_startup-0.0.1-SNAPSHOT.jar

执行读取和写入文件

文件读写和分析,参考代码:Section01Bootstrap.java

文件读取是从 classpath 读取的,相关代码如下:

InputStream in = Section01Bootstrap.class.getClassLoader().getResourceAsStream("service.txt");
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String line;
while ((line = br.readLine()) != null) {
    ...
}

执行工程打包后,需要在运行时将文件的路径加入到 classpath 上:

$ java -jar -cp=.:./files/* itrace_startup-0.0.1-SNAPSHOT.jar

集成 JPA

spring-boot-starter-data-jpa 是非常轻量级的 ORM 框架。

只要创建实体(CustCustGroup)、创建接口(CustRepositoryCustGroupRepository)即可完成对数据库表到对象的 ORM 访问。

具体参考:CustController -> CustRepository -> Cust

启动时报错

需要在 application.properties 文件指定的数据库实例上创建 itrace_startup 数据库。

参考材料

to-do

  • 实现选拔赛题目一
  • 实现选拔赛题目二
  • 集成文件读取和写入(从 classpth)
  • 集成简单的web/http 功能
  • 集成轻量级的ORM 框架(JPA)
  • 集成 Dubbo

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.