full_name
stringlengths
7
104
description
stringlengths
4
725
topics
stringlengths
3
468
readme
stringlengths
13
565k
label
int64
0
1
BrentAureli/FlappyDemo
YouTube Tutorial Series - Creating Flappy Birds
null
# FlappyDemo
1
timClicks/tutorials
Code for (video) tutorials
null
# tutorials Code for (video) tutorials
0
micronaut-projects/micronaut-guides
Guides and Tutorials on how to use Micronaut including sample code
groovy java kotlin micronaut tutorials
# Micronaut Guides This is the main repository for the [Micronaut Guides](https://guides.micronaut.io). ## Build the guides To build all the guides run: ```shell $ ./gradlew build ``` This will generate all the projects and guides in `build/dist` and this is what needs to be published to GitHub Pages. To build a single guide, run the dynamic task created by `GuidesPlugin`; convert the kabab case guide directory name to lowerCamelCase and add "Build", e.g. to build `micronaut-http-client`, run ```shell ./gradlew micronautHttpClientBuild ``` ## Create a new guide For a high level overview of the Guides Infrastructure, take a look at this [blog post](https://micronaut.io/2021/04/12/improving-the-micronaut-guides-infrastructure/). All the guides leverage [Micronaut Starter](https://github.com/micronaut-projects/micronaut-starter) core to create the projects. The idea is that one guide can generate up to six different projects, one per language (Java, Groovy and Kotlin) and build tool (Gradle and Maven). ### Guide structure All the guides are in the `guides` directory in separate subdirectories. Inside the directory, the main file is `metadata.json` that describes the guide. All the fields are declared in [GuideMetadata](https://github.com/micronaut-projects/micronaut-guides/blob/master/buildSrc/src/main/groovy/io/micronaut/guides/GuideMetadata.groovy) class. ```json { "title": "Micronaut HTTP Client", "intro": "Learn how to use Micronaut low-level HTTP Client. Simplify your code with the declarative HTTP client.", "authors": ["Sergio del Amo", "Iván López"], "tags": ["client", "rx", "flowable", "json-streams"], "category": "Getting Started", "publicationDate": "2018-07-02", "apps": [ { "name": "default", "features": ["graalvm", "reactor"] } ] } ``` Besides, the obvious fields that doesn't need any further explanation, the other are: - `tags`: List of tags added to the guide. You don't need to include the language here because it is added automatically when generating the json file for the Guides webpage. - `category`: Needs to be a valid value from the [Category](https://github.com/micronaut-projects/micronaut-guides/blob/master/buildSrc/src/main/java/io/micronaut/guides/Category.java) enum. - `buildTools`: By default we generate the code in the guides for Gradle and Maven. If a guide is specific only for a build tool, define it here. - `languages`: The guides should be written in the three languages. Sometimes we only write guides in one language or the guide only supports a specific language. - `testFramework`: By default Java and Kotlin applications are tested with JUnit5 and Groovy applications with Spock. In some cases we have Java guides that are tested with Spock. Use this property to configure it. - `skipGradleTests`: Set it to `true` to skip running the tests for the Gradle applications for the guide. This is useful when it's not easy to run tests on CI, for example for some cloud guides. - `skipMavenTests`: Same as `skipGradleTests` but for Maven applications. - `minimumJavaVersion`: If the guide needs a minimum Java version (for example JDK 17 for Records), define it in this property. - `maximumJavaVersion`: If the guide needs a maximum Java version (for example JDK 11 for Azure Functions), define it in this property. - `zipIncludes`: List of additional files to include in the generated zip file for the guide. - `publish`: defaults to true for regular guides; set to false for partial/base guides - `base`: defaults to null; if set, indicates directory name of the base guide to copy before copying the current - `apps`: List of pairs `name`-`features` for the generated application. There are two types of guides, most of the guides only generate one application (single-app). In this case the name of the applications needs to be `default`. There are a few guides that generate multiple applications, so they need to be declared here: ```json ... "apps": [ { "name": "bookcatalogue", "features": ["tracing-jaeger", "management"] }, { "name": "bookinventory", "features": ["tracing-jaeger", "management"] }, { "name": "bookrecommendation", "features": ["tracing-jaeger", "management", "reactor"] } ] ``` The features need to be **valid** features from Starter because the list is used directly when generating the applications using Starter infrastructure. If you need a feature that is not available on Starter, create it in `buildSrc/src/main/java/io/micronaut/guides/feature`. Also declare the GAV coordinates and version in `buildSrc/src/main/resources/pom.xml`. Dependabot is configured in this project to look for that file and send pull requests to update the dependencies. Inside the specific guide directory there should be a directory per language with the appropriate directory structure. All these files will be copied into the final guide directory after the guide is generated. ```shell micronaut-http-client ├── groovy │ └── src │ ├── main │ │ └── groovy │ │ └── example │ │ └── micronaut │ └── test │ └── groovy │ └── example │ └── micronaut ├── java │ └── src │ ├── main │ │ └── java │ │ └── example │ │ └── micronaut │ └── test │ └── java │ └── example │ └── micronaut ├── kotlin │ └── src │ ├── main │ │ └── kotlin │ │ └── example │ │ └── micronaut │ └── test │ └── kotlin │ └── example │ └── micronaut └── src └── main └── resources ``` For multi-applications guides there needs to be an additional directory with the name of the application declared in `metadata.json` file: ```shell micronaut-microservices-distributed-tracing-zipkin ├── bookcatalogue │ ├── groovy │ │ ... │ ├── java │ │ ... │ └── kotlin │ ... ├── bookinventory │ ├── groovy │ │ ... │ ├── java │ │ ... │ └── kotlin │ ... └── bookrecommendation ├── groovy │ ... ├── java │ ... └── kotlin ``` ### Writing the guide There is only one Asciidoctor file per guide in the root directory of the guide (sibling to `metadata.json`). This unique file is used to generate all the combinations for the guide (language and build tool) so we need to take that into account when writing the guide. Name the Asciidoctor file the same as the directory, with an "adoc" extension, e.g. `micronaut-http-client.adoc` for the `micronaut-http-client` guide directory. We don't really write a valid Asciidoctor file but our "own" Asciidoctor with custom kind-of-macros. Then during the build process we render the final HTML for the guide in two phases. In the first one we evaluate all of our custom macros and include and generate a new language-build tool version of the guide in `src/doc/asciidoc`. This directory is excluded from source control and needs to be considered temporary. Then we render the final HTML of the (up to) six guides from that generated and valid Asciidoctor file. #### Placeholders You can use the following placeholders while writing a guide: * `@language@` * `@guideTitle@` * `@guideIntro@` * `@micronaut@` * `@lang@` * `@build@` * `@testFramework@` * `@authors@` * `@languageextension@` * `@testsuffix@` * `@sourceDir@` * `@minJdk@` * `@api@` * `@features@` * `@features-words@` #### Common snippets We have small pieces of text that are used in different guides. To avoid the duplication we have common snippets in the `src/docs/common` directory. For example the file `common-header-top.adoc`: ```asciidoc = @guideTitle@ @guideIntro@ Authors: @authors@ Micronaut Version: @micronaut@ ``` Will render the title, description, authors and version of all the guides. The variables defined between `@` signs will be evaluated and replaced during the first stage of the asciidoctor render. For example, for the Micronaut HTTP Client guide, the previous common snippet will generate: ```asciidoc // Start: common-header-top.adoc = Micronaut HTTP Client Learn how to use Micronaut low-level HTTP Client. Simplify your code with the declarative HTTP client. Authors: Sergio del Amo, Iván López Micronaut Version: 3.2.7 // End: common-header-top.adoc ``` #### Custom macros There are a number of custom macros available to make it easy writing a single asciidoctor file for all the guides and include the necessary source files, resources,... This is really important because when we include a source code snippet the base directory will change for every language the guide is written. The following snippet from the HTTP Client guide: ```asciidoc source:GithubConfiguration[] ``` Will generate the following Asciidoctor depending on the language of the guide: - Java: ```asciidoc [source,java] .src/main/java/example/micronaut/GithubConfiguration.java ---- include::{sourceDir}/micronaut-http-client-gradle-java/src/main/java/example/micronaut/GithubConfiguration.java[] ---- ``` - Groovy: ```asciidoc [source,groovy] .src/main/groovy/example/micronaut/GithubConfiguration.groovy ---- include::{sourceDir}/micronaut-http-client-gradle-groovy/src/main/groovy/example/micronaut/GithubConfiguration.groovy[] ---- ``` - Kotlin: ```asciidoc [source,kotlin] .src/main/kotlin/example/micronaut/GithubConfiguration.kt ---- include::{sourceDir}/micronaut-http-client-gradle-kotlin/src/main/kotlin/example/micronaut/GithubConfiguration.kt[] ---- ``` As you can see, the macro takes care of the directories (`src/main/java` vs `src/main/groovy` vs `src/main/kotlin`) and the file extension. Following this same approach there are macros like: - `source`: Already explained. - `resource`: To include a file from the `src/main/resources` directory. - `test`: To include a file from the `src/main/test` directory. This macro also takes care of the suffix depending on the test framework. For example, with `test:GithubControllerTest[]` the macro will reference the file `GithubControllerTest.java` (or .kt) for Java and Kotlin and `GithubControllerSpec.groovy` for Groovy. - `testResource`: To include a file from the `src/main/test/resources` directory. - `callout`: To include a common callout snippet. In all the cases it is possible to pass additional parameters to the macros to customise them. For example, to extract a custom tag from a snippet, we can do `resource:application.yml[tag=githubconfig]`. Look for usages of those macros in the `guides` directory to find more examples. #### Special custom blocks There are also special custom blocks to exclude some code to be included in the generated guide based on some condition. This is useful when explaining something specific of the build tool (like how to run the tests with Gradle or Maven) or to exclude something depending on the language (for example do not render the GraalVM section in Groovy guides, as Groovy is not compatible with GraalVM). Example: ```asciidoc :exclude-for-languages:kotlin <2> The Micronaut framework will not load the bean unless configuration properties are set. :exclude-for-languages: :exclude-for-languages:java,groovy <2> Kotlin doesn't support runtime repeatable annotations (see https://youtrack.jetbrains.com/issue/KT-12794[KT-12794]. We use a custom condition to enable the bean where appropriate. :exclude-for-languages: ``` For Java and Groovy guides the first block will be included. For Kotlin guide, the second block will be included. Example for build tool: ```asciidoc :exclude-for-build:maven Now start the application. Execute the `./gradlew run` command, which will start the application on port 8080. :exclude-for-build: :exclude-for-build:gradle Now start the application. Execute the `./mvnw mn:run` command, which will start the application on port 8080. :exclude-for-build: ``` For a Gradle guide, the first block will be included. For a Maven guide, the second one will be included. As before, look for usages of the macro in the `guides` directory for more examples. ### New Guide Template To create a new guide use the following template as the base asciidoc file: ```asciidoc common:header.adoc[] common:requirements.adoc[] common:completesolution.adoc[] common:create-app.adoc[] TODO: Describe the user step by step how to write the app. Use includes to reference real code: Example of a Controller source:HelloController[] Example of a Test test:HelloControllerTest[] common:testApp.adoc[] common:runapp.adoc[] common:graal-with-plugins.adoc[] :exclude-for-languages:groovy TODO describe how you consume the endpoints exposed by the native executable with curl :exclude-for-languages: TODO Use the generic next step common:next.adoc[] TODO or a personalised guide for the guide: == Next steps TODO: link to the documentation modules you used in the guide ``` ### Testing the guide When working on a new guide, generate it as explained before. The guide will be available in the `build/dist` directory and the applications will be in the `build/code` directory. You can open any directory in `build/code` directly in your IDE to make any changes but keep in mind copying the code back to the appropriate directory. In the `build/code` directory a file `test.sh` is created to run all the tests for the guides generated. Run it locally to make sure it passes before submitting a new pull request. You can run this test with a gradle task ```bash ./gradlew :____RunTestScript ``` where `____` is the camel-case name of your guide. eg: ```bash ./gradlew micronautFlywayRunTestScript ``` to run all the tests for the `micronaut-flyway` guide. ## Upgrade Micronaut version When a new Micronaut version is released, update the [version.txt](https://github.com/micronaut-projects/micronaut-guides/blob/master/version.txt) file in the root directory. Submit a new pull request and if the build passes, merge it. A few minutes later all the guides will be upgraded to the new version. ## Deployment Guides are published to [gh-pages](https://pages.github.com) following the same branch structure as Micronaut Core: - One directory per Micronaut minor version: `3.0.x`, `3.1.x`, `3.2.x`,... - One directory with the latest version of the guide: `latest` ## GitHub Actions There are two main jobs: - Java CI: Run everytime we send a pull request or something is merged in `master`. The `test.sh` script explained before is executed. - Java CI SNAPSHOT: There is a cronjob that runs daily the tests for the new Micronaut patch and minor versions to make sure everything will work when we release new versions in the future.
1
eshioji/trident-tutorial
A practical Storm Trident tutorial
null
trident-tutorial ================ A practical Storm Trident tutorial This tutorial builds on [Pere Ferrera][1]'s excellent [material][2] for the [Trident hackaton@Big Data Beers #4 in Berlin][3]. The vagrant setup is based on Taylor Goetz's [contribution][6]. The Hazelcast state code is based on wurstmeister's [code][7]. [1]:https://github.com/pereferrera [2]:https://github.com/pereferrera/trident-hackaton [3]:http://www.meetup.com/Big-Data-Beers/events/112226662/ [6]:https://github.com/ptgoetz/storm-vagrant [7]:https://github.com/wurstmeister/storm-kafka-0.8-plus-test Have a look at the accompanying [slides][4] as well. [4]:http://htmlpreview.github.io/?https://rawgithub.com/mischat/trident-tutorial/blob/master/slides/index.html#(4) ## How this tutorial is structured * Go through Part*.java to learn about the basics of Trident * Implement your own topology using Skeleton.java, or have a look at other examples ``` ├── environment ------ Vagrant resources to simulate a Storm cluster locally ├── src    └── main    ├── java    │   └── tutorial    │   └── storm    │   ├── trident    │   | ├── example ------ Complete examples    │   | ├── operations ------ Functions and filters that is used in the tutorial/examples    │   | └── testutil ------ Test utility classes (e.g test data generators)    | | └── TweetIngestor ------ Creates a local Kafka broker that streams twitter public stream    | ├── Part*.java ------ Illustrates usage of Trident step by step.    | └── Skeleton.java ------ Stub for writing your own topology    └── resources    └── tutorial    └── storm    └── trident    └── testutil ------ Contains test data and config files ``` ## Before you run the tutorials 1. Install Java 1.6 and Maven 3 (these versions are recommended, but you can also use Java 1.7 and/or Maven 2) 2. Clone this repo (if you don't have git, you can also download the source as zip file and extract it) 3. Go to the project folder and execute `mvn clean package`, and see if the build succeeds ## Going through Part*.java These classes are primarily meant to be read, but you can run them as well. Before you run the main method, you should comment out all streams except the one you are interested in (otherwise there will be lots of output) ## Running the Skeleton and examples These toplogies expect a Kafka spout that streams tweets. The Kafka spout needs a Kafka queue. There is a utility class called `Tweetingestor` which starts a local Kafka broker, connects to twitter and publishes tweets. To use this class however, you must provide a valid twitter access token in `twitter4j.properties` file. To do that, 1. Go to https://dev.twitter.com and register 2. Create an application and obtain a consumer key, consumer secret, access token and an access secret 3. Copy `twitter4j.properties.template` as `twitter4j.properties` and replcace the `*******` with real credentials 4. After that, execute ```bash java -cp target/trident-tutorial-0.0.1-SNAPSHOT-jar-with-dependencies.jar \ tutorial.storm.trident.Skeleton ``` ## Running a Storm cluster You can simulate a multi-machine Storm cluster on your local machine. To do this, first install [vagrant][5]. Then, install its host manager plugin by executing ``` $ vagrant plugin install vagrant-hostmanager ``` Finally, go to `./environment` and execute `vagrant up`. It will take a while to download necessary resources, and you will be asked for root password as it edits the host file. You can list the vagrant VMs as follows: ``` $ vagrant status Current machine states: util running (virtualbox) zookeeper running (virtualbox) nimbus running (virtualbox) supervisor1 running (virtualbox) supervisor2 running (virtualbox) ``` The vagrant configuration file is configured to forward standard storm/kafka/zookeeper ports from the host machine (i.e. your machine) to the appropriate guest VM, so that you can e.g. look at Storm UI by simply navigating to `http://localhost:8080`. You can ssh into these machines by doing e.g. `vagrant ssh nimbus` and take a look. Storm components are run by the `storm` user. [5]:http://www.vagrantup.com/ ## Running example topologies on the Storm cluster ### Start the Kafka server Currently you have to start the Kafka server manually. To do so, ssh into the `util` server like so: ``` vagrant ssh util ``` Then, start the Kafka server in the background ``` sudo /bin/su - kafka -c "/usr/share/kafka_2.8.0-0.8.1.1/bin/kafka-server-start.sh -daemon /usr/share/kafka_2.8.0-0.8.1.1/config/server.properties" ``` ### Start the Tweet Ingestor Get Twitter API tokens at https://dev.twitter.com Copy `./src/main/resources/twitter4j.properties.template` as `twitter4j.properties` in the same directory, and replace `********` with your actual token/secret etc. Once you've done that, execute `tutorial.storm.trident.testutil.TweetIngestor localhost 9092 1.0`. The process will connect to Twitter and post the Tweets to the Kafka broker through the port-forwarding we set up on 9092. The last argument `1.0` will limit the number of Tweets that will be posted to 1.0/second in order to not overload our small virtual cluster! If you see something like this in the logs, it's working ok ``` 660391 [metrics-logger-reporter-thread-1] INFO tutorial.storm.trident.testutil.TweetIngestor - type=TIMER, name=tweet-ingestion, count=33386, min=0.054, max=1.0779999999999998, mean=0.1831284046692607, stddev=0.09167078947103646, median=0.16699999999999998, p75=0.215, p95=0.3150999999999999, p98=0.46509999999999974, p99=0.5769400000000005, p999=1.0721420000000006, mean_rate=50.751326369025925, m1=50.833859244762294, m5=51.93631323103864, m15=52.897234973285414, rate_unit=events/second, duration_unit=milliseconds ``` ### Build and deploy the example topology Build a job jar like so: ``` mvn clean package -DskipTests -Pcluster ```
1
vaadin/flow-crm-tutorial
Demo app for the Java Web App tutorial series
java java-web spring-boot tutorial vaadin
# Spring Boot and Vaadin course source code This repository contains the source code for the [Building Modern Web Applications With Spring Boot and Vaadin](https://vaadin.com/docs/latest/flow/tutorials/in-depth-course). *Live demo:* https://crm.demo.vaadin.com ## Running the Application There are two ways to run the application: using `mvn` or by running the `Application` class directly from your IDE. ## Branches - The main branch contains the source code for the latest Vaadin release - The `v14` branch contains the source code for Vaadin 14 ## Text tutorial You can find a text version of the tutorial in the [Vaadin Documentation](https://vaadin.com/docs/latest/flow/tutorials/in-depth-course).
1
jimwebber/neo4j-tutorial
A koan-style tutorial in Java for Neo4j
null
null
1
kairen/learning-spark
Tidy up Spark and Hadoop tutorials.
bigdata data-science hadoop spark
# Spark training 本項目將所有於分享會以及課程上,所接觸的系統建置、Spark API 撰寫、HDFS 操作...等教學與整理,主要授課人員為 NUTC imac 內部團隊自我訓練。 ### 主要包含項目 1. Spark 概念、部署與基本範例 2. Hadoop 概念、部署與基本範例 3. Spark 與 Hadoop 相關系統建置整理 > 以上內容我們會逐一整理,並寫成文件來分享給大家。 ### 參與貢獻 任何團隊成員都可以對該 git 做貢獻,未來也會請大家針對不一樣的作業進行提交,一個基本的貢獻流程如下所示: 1. 在 `Github` 上 `fork` 到自己的 Repository,例如:`<User>/learning-spark.git`,然後 ```clone```到 local 端,並設定 Git 使用者資訊。 ```sh git clone https://github.com/kairen/learning-spark.git cd spark-tutorial git config user.name "User" git config user.email user@email.com ``` 2. 修改程式碼或頁面後,透過 `commit` 來提交到自己的 Repository: ```sh git commit -am "Fix issue #1: change helo to hello" git push ``` > 若新增採用一般文字訊息,如`Add Spark MLlib example ...`。 3. 在 GitHub 上提交一個 Pull Request。 4. 持續的針對 Project Repository 進行更新內容: ```sh git remote add upstream https://github.com/kairen/learning-spark.git git fetch upstream git checkout master git rebase upstream/master git push -f origin master ```
0
SamirPaulb/Java
Java Programming Tutorial for Beginners
code java java-programming java8 java9 programming-language project-template tutorials
# Java Overview ## https://github.com/SamirPaul1/SamirPaul1.JAVA ### Introduction We love Programming. Our aim with this course is to create a love for Programming. Java is one of the most popular programming languages. Java offers both object oriented and functional programming features. We take an hands-on approach using a combination of JShell(An awesome new feature in Java 9) and Eclipse as an IDE to illustrate more than 200 Java Coding Exercises, Puzzles and Code Examples. In more than 250 Steps, we explore the most important Java Programming Language Features - Basics of Java Programming - Expressions, Variables and Printing Output - Java Operators - Java Assignment Operator, Relational and Logical Operators, Short Circuit Operators - Java Conditionals and If Statement - Methods - Parameters, Arguments and Return Values - An Overview Of Java Platform - java, javac, bytecode, JVM and Platform Independence - JDK vs JRE vs JVM - Object Oriented Programming - Class, Object, State and Behavior - Basics of OOPS - Encapsulation, Abstraction, Inheritance and Polymorphism - Basics about Java Data Types - Casting, Operators and More - Java Built in Classes - BigDecimal, String, Java Wrapper Classes - Conditionals with Java - If Else Statement, Nested If Else, Java Switch Statement, Java Ternary Operator - Loops - For Loop, While Loop in Java, Do While Loop, Break and Continue - Immutablity of Java Wrapper Classes, String and BigDecimal - Java Dates - Introduction to LocalDate, LocalTime and LocalDateTime - Java Array and ArrayList - Java String Arrays, Arrays of Objects, Primitive Data Types, toString and Exceptions - Introduction to Variable Arguments - Basics of Designing a Class - Class, Object, State and Behavior. Deciding State and Constructors. - Understanding Object Composition and Inheritance - Java Abstract Class and Interfaces. Introduction to Polymorphism. - Java Collections - List Interface(ArrayList, LinkedList and Vector), Set Interface (HashSet, LinkedHashSet and TreeSet), Queue Interface (PriorityQueue) and Map Interface (HashMap, HashTable, LinkedHashMap and TreeMap() - Compare, Contrast and Choose - Generics - Why do we need Generics? Restrictions with extends and Generic Methods, WildCards - Upper Bound and Lower Bound. - Functional Programming - Lambda Expression, Stream and Operations on a Stream (Intermediate Operations - Sort, Distinct, Filter, Map and Terminal Operations - max, min, collect to List), Functional Interfaces - Predicate Interface,Consumer Interface, Function Inteface for Mapping, Method References - static and instance methods - Introduction to Threads and MultiThreading - Need for Threads - Implementing Threads - Extending Thread Class and Implementing Runnable Interface - States of a Thread and Communication between Threads - Introduction to Executor Service - Customizing number of Active Threads. Returning a Future, invokeAll and invokeAny - Introduction to Exception Handling - Your Thought Process during Exception Handling. try, catch and finally. Exception Hierarchy - Checked Exceptions vs Unchecked Exceptions. Throwing an Exception. Creating and Throwing a Custom Exception - CurrenciesDoNotMatchException. Try with Resources - New Feature in Java 7. - List files and folders in Directory with Files list method, File walk method and find methods. Read and write from a File. --- ### What You will learn - You will learn how to think as a Java Programmer - You will learn how to start your journey as a Java Programmer - You will learn the basics of Eclipse IDE and JShell - You will learn to develop awesome object oriented programs with Java - You will solve a wide variety of hands-on exercises on the topics discussed below - You will learn the basics of programming - variables, choosing a data type, conditional execution, loops, writing great methods, breaking down problems into sub problems and implementing great Exception Handling. - You will learn the basics of Object Oriented Programming - Intefaces, Inheritance, Abstract Class and Constructors - You will learn the important concepts of Object Oriented Programming - Abstraction, Inheritance, Encapsulation and Polymorphism - You will learn to do basic functional programming with Java - You will learn the basics of MultiThreading - with Executor Service - You will learn about a wide variety of Collections - List, Map, Set and Queue Interfaces --- ### Requirements - Connectivity to Internet to download Java 9 and Eclipse. - We will help you install Java9 with JShell and Eclipse.
1
RameshMF/servlet-tutorial
A complete Java servlet 4 tutorial for beginners as well as professionals
null
# servlet-tutorial A complete Java servlet 4 tutorial for beginners as well as professionals <div> <div style="text-align: left;"> </div> <ul style="text-align: left;"> <li><a href="https://www.javaguides.net/2019/03/servlet-jsp-jdbc-mysql-example.html" target="_blank">Servlet + JSP + JDBC + MySQL Example</a></li> </ul> <ul style="text-align: left;"> <li><a href="https://www.javaguides.net/2019/03/registration-form-using-jsp-servlet-jdbc-mysql-example.html" target="_blank">Registration Form using JSP + Servlet + JDBC + Mysql Example</a></li> </ul> <ul style="text-align: left;"> <li><a href="https://www.javaguides.net/2019/03/login-form-using-jsp-servlet-jdbc-mysql-example.html" target="_blank">Login Form using JSP + Servlet + JDBC + MySQL Example</a></li> </ul> <ul style="text-align: left;"> <li><a href="https://www.javaguides.net/2019/09/upload-file-to-database-with-servlet-jsp-jdbc-mysql-using-blob.html" target="_blank">Upload File to Database with Servlet,JSP,JDBC and MySQL using BLOB</a></li> </ul> </div>
1
errai/errai-tutorial
Errai tutorial project
null
Errai Getting Started Demo ===================== This simple demo allows users to create contact entires for an address book. The user interface is designed using plain HTML5 and CSS. Errai UI enables the injection of UI fields into client-side Java classes as well as adding dynamic behaviour to these fields (such as event handlers). The demo also makes use of Errai's two-way data binding and page navigation modules. This can all be seen in `ContactListPage.java` (the markup for which can be found in `contact-page.html`). Creating contacts is done using a simple JAX-RS endpoint and Errai's typesafe REST caller support (see the `@EventHandler` method for the submit button in `ContactListPage.java`). Every time a new contact is created, the server will fire a CDI event which will be observed by all connected clients (new contacts will automatically appear in the displayed contact lists of all connected clients). The relevant code for firing and observing this CDI event can be found in `ContactStorageServiceImpl.java` and `ContactListPage.java`. The filed contacts are persisted on the server. This demo is designed to work with a full Java EE 7 server such as WildFly 10. Although it should be possible to craft a deployment of this demo to a simpler web server, it's much simpler to deploy to an EE 7 capable app server. Prerequisites ------------- * Maven 3 (run `mvn --version` on the command line to check) * An unzipped copy of WildFly 10 (Optional) More detailed instructions can be found in our [Setup Tutorial](tutorial-guide/SETUP.adoc) Build and deploy (production mode) ---------------- To build a .war file and deploy it to the local running WildFly instance: % mvn clean package wildfly:deploy Once the above command has completed, you should be able to access the app at the following URL: http://localhost:8080/errai-tutorial More detailed instructions can be found [here](tutorial-guide/RUN.adoc) Code and Refresh (development mode) ---------------- Using GWT's Super Dev Mode, it is possible to instantly view changes to client-side code by simply refreshing the browser window. ======= http://localhost:8080/errai-crud Code and Refresh (development mode) ----------------------------------- Using GWT's Super Dev Mode, it is possible to instantly view changes to client-side code simply by refreshing the browser window. If you're using the Google Plugin for Eclipse or IntelliJ Ultimate Edition follow [these instructions](http://docs.jboss.org/errai/latest/errai/reference/html_single/#_running_and_debugging_in_your_ide_using_gwt_tooling) to start development mode. Alternatively, you should be able to start the demo in development mode with this single command: % mvn clean gwt:run When the GWT Dev Mode window opens, press "Launch Default Browser" to start the app. You can now debug client-side code directly in the browser using source maps (make sure source maps are enabled in your browser). Alternatively, you can also configure a debug environment for Eclipse by installing - the Google Plugin for Eclipse: https://developers.google.com/eclipse/docs/download - the SDBG plugin: http://sdbg.github.io/ To debug server-side code, set up a remote debugger on port 8001. Then: * Run `mvn clean gwt:debug` * Start your remote debugger * Press "Launch Default Browser" See our development guide [here](tutorial-guide/DEVELOP.adoc) for more instructions on setting up dev mode and other details. Troubleshooting --------------- Here are some resources that may help if you encounter difficulties: * [FAQ](tutorial-guide/FAQ.adoc) * [Forum](https://community.jboss.org/en/errai) * IRC : #errai @ freenode
1
aws1994/HomeDashboard
youtube tutorial : https://youtu.be/-YCUrHFUxlA
null
null
1
chtrembl/azure-cloud
Here you will find various Azure Demos & Tutorials that I've put together for Azure Cloud using DevOps, Container Services and other PaaS offerings.
apim app application-insights application-security azure b2c containers devops java kubernetes spring
null
0
Antabot/White-Jotter
白卷是一款使用 Vue+Spring Boot 开发的前后端分离项目,附带全套开发教程。(A simple CMS developed by Spring Boot and Vue.js with development tutorials)
restful single-page-app spring-boot springdata-jpa vue
![wjlogo.png](https://i.loli.net/2019/12/15/sYnuTIrDUwAfGgo.png) --- ![lisense](https://img.shields.io/github/license/Antabot/White-Jotter) ![release](https://img.shields.io/github/v/release/Antabot/White-Jotter) 这是一个简单的项目,旨在让新入门 web 的开发者体验使用 Vue + Java(Spring Boot) + Mysql 以前后端分离模式完成开发的流程。由于开发过程中并未充分考虑安全防护问题,并不建议将该项目用于生产环境。 https://github.com/Antabot/White-Jotter) 感谢 JetBrains 提供全家桶开源许可,IDEA 确实是 Java 领域最好用的 IDE。 <a href="https://www.jetbrains.com/?from=White-Jotter"><img src="https://i.loli.net/2020/06/15/wfyV6jGX8F9RPhB.png" width = "200" height = "216" alt="" align=center /></a> # 整体效果 ## 首页 作为展示页面,包括开发这个项目的主要参考资料、近期更新和 Slogan ![首页](https://img-blog.csdnimg.cn/20190403215932913.png) ## 图书馆 提供图书信息展示功能 ![图书馆](https://i.loli.net/2019/12/03/AGLbIupct68ThBD.png) ## 笔记本 提供笔记、博文展示功能 ![笔记本首页.png](https://i.loli.net/2020/01/20/VAsOapuWriB6RFT.png) ![文章内容.png](https://i.loli.net/2020/01/20/DQgbpy2LKhiZc4x.png) ## 后台管理 包含 dashboard、内容管理、用户及权限管理等 ![后台](https://img-blog.csdnimg.cn/20191202200516251.png) # 架构图 - **应用架构** ![应用架构](https://img-blog.csdnimg.cn/20200524211402855.JPG) - **技术架构** ![技术架构](https://img-blog.csdnimg.cn/20200524211507112.JPG) # 主要技术栈 ## 前端 1.Vue.js 2.ElementUI 3.axios ## 后端 1.Spring Boot 2.Apache Shiro 3.Apache Log4j2 4.Spring Data JPA 5.Spring Data Redis ## 数据库 1.MySQL 2.Redis # 部署方法 1.clone 项目到本地 `git clone https://github.com/Antabot/White-Jotter` 2.在 mysql 中创建数据库 `wj`,运行项目,将自动注入数据。如需关闭此功能,请将 `application.properties` 中的 `spring.datasource.initialization-mode=always` 代码删除。 数据库完整脚本 `wj.sql` 放在后端项目的 `src\main\resources` 目录下,也可根据需要自行在 MySQL 中执行数据库脚本。 运行项目前请启动 Redis 服务,端口为 6379(默认端口),密码为空。 3.数据库配置在后端项目的 `src\main\resources` 目录下的`application.properties` 文件中,mysql 版本为 8.0.15 。 4.在IntelliJ IDEA中运行后端项目,为了保证项目成功运行,可以右键点击 `pom.xml` 选择 maven -> reimport ,并重启项目 至此,服务端就启动成功了,同时,运行前端项目,访问 `http://localhost:8080` ,即可进入登录页面,默认账号是 `admin`,密码是 `123` 如果要做二次开发,请继续看第五、六步。 5.进入前端项目根目录中,在命令行依次输入如下命令: ``` # 安装依赖 npm install # 在 localhost:8080 启动项目 npm run dev ``` 由于在 `wj-vue` 项目中已经配置了端口转发,将数据转发到SpringBoot上,因此项目启动之后,在浏览器中输入 `http://localhost:8080` 就可以访问我们的前端项目了,所有的请求通过端口转发将数据传到 SpringBoot 中(注意此时不要关闭 SpringBoot 项目)。 6.最后可以用 `WebStorm` 等工具打开 `wj-vue`项目,继续开发,开发完成后,当项目要上线时,依然进入到 `wj-vue` 目录,然后执行如下命令: ``` npm run build ``` 该命令执行成功之后, `wj-vue` 目录下生成一个 `dist` 文件夹,可以将该文件夹中的两个文件 `static` 和 `index.html` 拷贝到 `wj` 项目中 `resources/static/` 目录下,然后直接运行 `wj` 项目,访问 `http://localhost:8443` ,实际上是把前端打包后作为静态文件,但不推荐使用这种方式。 前后端分离部署的方式详见教程第十篇:[「图片上传与项目的打包部署」](https://learner.blog.csdn.net/article/details/97619312) # 教程 我在 CSDN 上分享了开发这个项目的教程: 1.[项目简介](https://blog.csdn.net/Neuf_Soleil/article/details/88925013) 2.[使用 CLI 搭建 Vue.js 项目](https://blog.csdn.net/Neuf_Soleil/article/details/88926242) 3.[前后端结合测试(登录页面开发)](https://blog.csdn.net/Neuf_Soleil/article/details/88955387) 4.[数据库的引入](https://blog.csdn.net/Neuf_Soleil/article/details/89294300) 5.[使用 Element 辅助前端开发](https://blog.csdn.net/Neuf_Soleil/article/details/89298717) 6.[前端路由与登录拦截器](https://learner.blog.csdn.net/article/details/89422585) 7.[导航栏与图书页面设计](https://learner.blog.csdn.net/article/details/89853305) 8.[数据库设计与增删改查](https://learner.blog.csdn.net/article/details/92413933) 9.[核心功能的前端实现](https://learner.blog.csdn.net/article/details/95310666) 10.[图片上传与项目的打包部署](https://learner.blog.csdn.net/article/details/97619312) 11.[用户角色权限管理模块设计](https://learner.blog.csdn.net/article/details/100849732) 12.[访问控制及其实现思路](https://learner.blog.csdn.net/article/details/101121899) 13.[使用 Shiro 实现用户信息加密与登录认证](https://learner.blog.csdn.net/article/details/102690035) 14.[用户认证方案与完善的访问拦截](https://learner.blog.csdn.net/article/details/102788866) 15.[动态加载后台菜单](https://learner.blog.csdn.net/article/details/103114893) 16.[功能级访问控制的实现](https://learner.blog.csdn.net/article/details/103250775) 17.[后台角色、权限与菜单分配](https://learner.blog.csdn.net/article/details/103603726) 18.[博客功能开发](https://learner.blog.csdn.net/article/details/104033436) 19.[项目优化解决方案](https://learner.blog.csdn.net/article/details/104763090) (持续更新中) # 重要更新 ## 2020 01-20 利用开源 markdown 编辑器实现文章展示与管理模块 --- ## 2019 12-01 实现功能级权限控制 11-30 利用 vue-elment-admin 项目完善后台界面设计 11-17 重构项目,完成搭建后台基础界面,实现按角色加载菜单,取消前台访问限制 04-27 使用前端拦截器,数据库迁移至 mysql 8.0.15,后台管理页面初始化 04-13 完成图片的上传功能 04-11 完成图书分类功能 04-08 完成图书分页功能 04-06 完成图书查询功能 04-05 完成图书修改功能 04-04 完成图书删除功能 04-03 完成图书新增功能
0
IHTSDO/SNOMED-in-5-minutes
Easy-to-use tutorials for accessing SNOMED APIs within 5 min using various programming languages
csharp curl java javascript python snomed snomed-api
# SNOMED In 5 Minutes This is an easy-to-use tutorial for accessing SNOMED APIs within 5 min using the SNOMED International terminology server, [Snowstorm](https://github.com/IHTSDO/snowstorm). ## Consider using a FHIR API Instead! The examples in this repository use the Snowstorm native API and although this API is open source it is tool-specific rather than part of a standard. If possible it's better to use a Terminology Server with a FHIR API because that is an open standard, supported by many server and client implementations in many programming langauges and libraries! Find the FHIR API of the public Snowstorm server here (for non-production use only): https://snowstorm.ihtsdotools.org/fhir [Other terminology servers are available](https://implementation.snomed.org/terminology-services). ## Table of Contents 1. [Project Structure](#project-structure) 2. [Examples](#examples) 3. [Resources](#resources) 4. [Contributing](#contributing) 5. [License](#license) ## Project Structure - top-level: aggregator for sub-modules (alphabetically): - android-client-snomed-browser: examples for use in an Android client - csharp-examples: examples with csharp (.net) - curl-examples: examples with curl - java-examples: examples with java - javascript-examples: examples with javascript - model: JAXB-enabled classes for representing the RF2 domain model - php-examples: examples with php - python3-examples: examples with python - rest-client: a Java client for the REST services - rest-client-csharp: a CSharp client for the REST services - ruby-examples: examples with Ruby based on the Python examples - go-examples: examples with golang ## Examples The following examples will be used to demonstrate accessing the SNOMED API through CSharp, Javascript, Curl, and Java (using Jersey). - Find a concept by a string (e.g. "heart attack") - Find/get a concept by a description SCTID (e.g. "679406011") - Find/get a concept by a concept SCTID (e.g. "109152007") - Find a concept by a string (e.g. "heart") but only in the Procedures semantic tag All of the examples use a hard coded URL, edition name, and version number which point to a server hosted by SNOMED International (www.snomed.org). These are the APIs that back the SNOMED International browser (<https://browser.ihtsdotools.org>) - baseUrl = <https://browser.ihtsdotools.org/snowstorm/snomed-ct/> **[Back to top](#table-of-contents)** ### Javascript - [Click for JavaScript examples.](../master/javascript-examples/ "JavaScript Examples") ### Curl - [Click for Curl examples.](../master/curl-examples/ "Curl Examples") ### Python - [Click for Python examples.](../master/python3-examples/ "Python Examples") ### Ruby - [Click for Ruby examples.](../master/ruby-examples/ "Ruby Examples") ### PHP - [Click for PHP examples.](../master/php-examples/ "PHP Examples") ### Golang - [Click for GO examples.](../master/go-examples/ "Golang Examples") **[Back to top](#table-of-contents)** ## Needing some TLC The following examples are out of date and need updating to wokr with Snowstorm. All contributions welcome! ### Android client - [Click for Android examples.](../master/android-client-snomed-browser/ "Android Examples") ### CSharp (.net) - [Click for CSharp examples.](../csharp/csharp-examples/ "CSharp Examples") ### Java - [Click for Java examples.](../master/java-examples/ "Java Examples") ## Further Documentation Find comprehensive documentation here: TBD ## Resources - SNOMED International SNOMED CT browser: <http://browser.ihtsdotools.org> - Snowstorm SNOMED CT Terminology Server: <https://github.com/IHTSDO/snowstorm> (REST documentation here <https://browser.ihtsdotools.org/snowstorm/snomed-ct/>) **[Back to top](#table-of-contents)** ## Contributing 1. Fork it! 2. Create your feature branch: `git checkout -b my-new-feature` 3. Commit your changes: `git commit -am 'Add some feature'` 4. Push to the branch: `git push origin my-new-feature` 5. Submit a pull request **[Back to top](#table-of-contents)** ## Current Contributors - [Brian Carlsen](https://github.com/bcarlsenca) - [Alejandro Lopez Osornio](https://github.com/alopezo) - [Jesse Efron](https://github.com/yishaiil) - [Philip Wilford](https://github.com/philipwilford) - [Omid Mavadati](https://github.com/mavao) - [Ahmed Mohamed](https://github.com/me2resh) - [Kai Kewley](https://github.com/kaicode) - [Other Contributors](https://github.com/IHTSDO/SNOMED-in-5-minutes/graphs/contributors) **[Back to top](#table-of-contents)** ## License Apache 2.0 See the included LICENSE file for details. **[Back to top](#table-of-contents)** ## Suggestions for Future Work - 'supporting registration for a British GP' (i.e. searching within the GP/FP reference set & the UK language reference set) - 'deriving ICD-10 codes from registered SNOMED concepts (i.e. retrieving all entries of a SNOMED-concept from the ICD-10 extended mapping reference set)
0
onstutorial/onstutorial
Instructions and Code for Open Networking Summit tutorials
null
This repo contains code needed for ONS tutorials, as well as a wiki with instructions. To get started, go to the [tutorial home page](http://github.com/onstutorial/onstutorial/wiki). Below are instructions for generating the VM used in the tutorial: Create a Lubuntu (lightweight Ubuntu) image. We used 12.10. TODO: add details on MN version and command for the script used. TODO: note FlowVisor install instructions. Add wiki content to enable offline, in-browser viewing: ``` cd ~/ git clone git://github.com/onstutorial/onstutorial.wiki ``` Install Gollum, a git-backed wiki webserver. ``` sudo apt-get install rubygems # deps for gollum build sudo apt-get install libxslt-dev libxml2-dev sudo gem install gollum sudo gem install wikicloth # this breaks at the end, when it's making documentation, but it still loads pages just fine. ``` Create useful desktop shortcuts. ``` # Name: ONS Tutorial Instructions # Exec: /usr/bin/chromium-browser localhost:4567 # Icon: www-browser ``` ``` # Name: Update ONS Tutorial # Exec: lxterminal -e '/home/mininet/onstutorial.wiki/update.sh' # Icon: default (no line needed, gear icon makes sense) ``` Set up Gollum to show instructions on boot, using Upstart, by making a file, /etc/init/gollum.conf, with these contents: ``` description "run gollum webserver" start on startup task exec /usr/local/bin/gollum /home/mininet/onstutorial.wiki ```
0
pauldeck/springmvc-2ed
Examples for Spring MVC: A Tutorial (Second Edition)" book"
null
# springmvc-2ed Examples for "Spring MVC: A Tutorial (Second Edition)" book (ISBN 9781771970310), Brainy Software (http://brainysoftware.com), April 2016 If you are not familiar with GIT, click the "Download ZIP" button above to download the apps as a zip file. Each sample application comes in both Spring Tool Suite (STS) and Eclipse projects. STS uses Maven as its dependency manager. If you are comfortable with Maven, STS is probably your best bet. If not, you can still use your beloved Eclipse to test the apps. To test a project, open Eclipse or STS and import the project (File > Import > Existing Projects into Workspace > browse to project directory)
1
makotogo/developerWorks
Code for tutorials and articles I have written for IBM developerWorks
null
# developerWorks Code for tutorials and articles I have written for IBM developerWorks # Articles ## Create an artificial neural network using the Neuroph Java framework: Dominate your office March Madness pool! * [Article, published 8 January 2018](https://www.ibm.com/developerworks/library/cc-artificial-neural-networks-neuroph-machine-learning/index.html) * [Code path](https://github.com/makotogo/developerWorks/tree/master/NcaaMarchMadness) # IoT and the Smart Home, Part 1 * [Article, published 28 March 2018](https://developer.ibm.com/tutorials/iot-smart-home-01) * [Code path](https://github.com/makotogo/developerWorks/tree/master/makoto-home-automation/node-red) # IoT and the Smart Home, Part 2 * [Article, published 28 March 2018](https://developer.ibm.com/tutorials/iot-smart-home-02/) * [Code path](https://github.com/makotogo/developerWorks/tree/master/makoto-home-automation/node-red) # IoT and the Smart Home, Part 3 * [Article, published 28 March 2018](https://developer.ibm.com/tutorials/iot-smart-home-03/) * [Code path (Node-RED Controller)](https://github.com/makotogo/developerWorks/tree/master/makoto-home-automation/node-red) * [Code path (Android controller app)](https://github.com/makotogo/developerWorks/tree/master/DeviceController) ## Intro to Kubernetes * [Video (YouTube)](https://youtu.be/DiWzujzol70) * [Code path](https://github.com/makotogo/developerWorks/tree/master/kubernetes)
0
traex/RetrofitExample
Example for one of my tutorials at http://blog.robinchutaux.com/blog/a-smart-way-to-use-retrofit/
null
RetrofitExample =============== ![RetrofitExample](https://github.com/traex/RetrofitExample/blob/master/header.png) Example for one of my tutorials at http://blog.robinchutaux.com/blog/a-smart-way-to-use-retrofit/ [Retrofit library](http://square.github.io/retrofit/) is a type-safe REST client for Android and Java created by [Square Open Source.](http://square.github.io/) With this library you can request the webservices of a REST api with POST, GET and more. This library is awesome and very useful, but you need a good architecture and a good practice to use it as best as possible.
1
goxr3plus/Java-Spectrum-Analyser-Tutorials
🦗 Java-Spectrum-Analyser-Tutorials for Pros
null
### [![AlexKent](https://user-images.githubusercontent.com/20374208/75432997-f5422100-5957-11ea-87a2-164eb98d83ef.png)](https://www.minepi.com/AlexKent) Support me joining PI Network app with invitation code [AlexKent](https://www.minepi.com/AlexKent) [![AlexKent](https://user-images.githubusercontent.com/20374208/75432997-f5422100-5957-11ea-87a2-164eb98d83ef.png)](https://www.minepi.com/AlexKent) --- # About Are you curious on how to make spectrum analysers in Java? Well the below tutorials plus the above code are the solution . [![Java Spectrum Analyser Tutorial](http://img.youtube.com/vi/lwlioga8Row/0.jpg)](https://www.youtube.com/watch?v=lwlioga8Row) ## Java Audio Tutorials and API's by GOXR3PLUS STUDIO - **Spectrum Analyzers** - [Java-Audio-Wave-Spectrum-API](https://github.com/goxr3plus/Java-Audio-Wave-Spectrum-API) ![image](https://github.com/goxr3plus/Java-Audio-Wave-Spectrum-API/raw/master/images/Screenshot_2.jpg?raw=true) - [Jave Spectrum Analyzers from Audio](https://github.com/goxr3plus/Java-Spectrum-Analyser-Tutorials) - [Capture Audio from Microphone and make complex spectrum analyzers](https://github.com/goxr3plus/Java-Microphone-Audio-Spectrum-Analyzers-Tutorial) - **Java multiple audio formats player** - [Java-stream-player](https://github.com/goxr3plus/java-stream-player) - **Speech Recognition/Translation/Synthenizers** - [Java Speech Recognition/Translation/Synthesizer based on Google Cloud Services](https://github.com/goxr3plus/java-google-speech-api) - [Java-Speech-Recognizer-Tutorial--Calculator](https://github.com/goxr3plus/Java-Speech-Recognizer-Tutorial--Calculator) - [Java+MaryTTS=Java Text To Speech](https://github.com/goxr3plus/Java-Text-To-Speech-Tutorial) - [Java Speech Recognition Program based on Google Cloud Services ](https://github.com/goxr3plus/Java-Google-Speech-Recognizer) - [Java Google Text To Speech](https://github.com/goxr3plus/Java-Google-Text-To-Speech) - [Full Google Translate Support using Java](https://github.com/goxr3plus/java-google-translator) - [Professional Java Google Desktop Translator](https://github.com/goxr3plus/Java-Google-Desktop-Translator) ### Example Usage ( Hey check [here](https://github.com/goxr3plus/Java-Spectrum-Analyser-Tutorials/tree/master/Part%201%20-%20Stereo%20Oscilloscope/src/application) ): ``` JAVA import javafx.application.Application; import javafx.scene.Cursor; import javafx.scene.Scene; import javafx.stage.Stage; import javax.swing.JFileChooser; import javax.swing.JOptionPane; import javax.swing.filechooser.FileNameExtensionFilter; public class Main extends Application { PlayerExample playerExample = new PlayerExample(); @Override public void start(Stage primaryStage) { try { // Scene Scene scene = new Scene(playerExample, 600, 600); scene.setCursor(Cursor.HAND); primaryStage.setScene(scene); // Show primaryStage.setOnCloseRequest(c -> System.exit(0)); primaryStage.show(); // Selection of song to play JFileChooser jFileChooser = new JFileChooser(); jFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); jFileChooser.setFileFilter(new FileNameExtensionFilter("audio","mp3","wav")); jFileChooser.setAcceptAllFileFilterUsed(false); while(true){ if(jFileChooser.showOpenDialog(null)==JFileChooser.APPROVE_OPTION){ playerExample.playSong(jFileChooser.getSelectedFile()); break; } else{ JOptionPane.showMessageDialog(null,"Please choose audio file","Select audio", JOptionPane.INFORMATION_MESSAGE); } } } catch (Exception ex) { ex.printStackTrace(); } } public static void main(String[] args) { launch(args); } } ```
0
spring-guides/tut-spring-boot-oauth2
Spring Boot and OAuth2:: A tutorial on social" login and single sign on with Facebook and Github"
null
null
1
goxr3plus/Java-Speech-Recognizer-Tutorial--Calculator
:lips: Java-Speech-Recognizer-Tutorial--Calculator
calculator speech-recognizer tutorial
### [![AlexKent](https://user-images.githubusercontent.com/20374208/75432997-f5422100-5957-11ea-87a2-164eb98d83ef.png)](https://www.minepi.com/AlexKent) Support me joining PI Network app with invitation code [AlexKent](https://www.minepi.com/AlexKent) [![AlexKent](https://user-images.githubusercontent.com/20374208/75432997-f5422100-5957-11ea-87a2-164eb98d83ef.png)](https://www.minepi.com/AlexKent) --- <h3 align="center" > Java Google Speech Api ( Library )</h3> <p align="center"> 🎤 </p> <p align="center"> <sup> <b> Java + <a href="https://cmusphinx.github.io/wiki/tutorialsphinx4/#overview" target="_black"> Sphinx 5</a> Tutorials </b> </sup> </p> --- [![HitCount](http://hits.dwyl.io/goxr3plus/Java-Speech-Recognizer-Tutorial--Calculator.svg)](http://hits.dwyl.io/goxr3plus/Java-Speech-Recognizer-Tutorial--Calculator) <a href="https://patreon.com/preview/8adae1b75d654b2899e04a9e1111f0eb" title="Donate to this project using Patreon"><img src="https://img.shields.io/badge/patreon-donate-yellow.svg" alt="Patreon donate button" /></a> <a href="https://www.paypal.me/GOXR3PLUSCOMPANY" title="Donate to this project using Paypal"><img src="https://img.shields.io/badge/paypal-donate-yellow.svg" alt="PayPal donate button" /></a> ## Before you start with anything watch these videos , hey i see you don't cheat :) | About CMU Sphinx5 | Full NetBeans Tutorial | |:-:|:-:| | [![First](http://img.youtube.com/vi/uFoqXJvJZeM/0.jpg)](https://www.youtube.com/watch?v=uFoqXJvJZeM) | [![Second](http://img.youtube.com/vi/UmU3yhbPIlI/0.jpg)](https://www.youtube.com/watch?v=UmU3yhbPIlI) | Also visit this repository -> https://github.com/goxr3plus/sphinx-5-Maven-Example -------------------------------------------------------------- > PS Java 1.8.0_64 ++ Required ! Download Java 8 here : ( https://www.java.com/en/ ) > Announcement , Now i more focused on Google Speech Recognition : [github repository here](https://github.com/goxr3plus/Java-Google-Speech-Recognizer) > In case you want to parse Sphinx4-5 Grammar Files check this Library : [JSFG-Grammar-Rules-Parser-Library-for-Sphinx4-5](https://github.com/goxr3plus/JSFG-Grammar-Rules-Parser-Library-for-Sphinx4-5) # Java-Speech-Recognizer-Tutorial--Calculator Follow this awesome tutorials to learn how to implement a speech recognizer in Java step by step using Sphinx4-5. ### ------------------------ FOLDERS EXPLANATION ------------------------ #### ------> All the libraries you need in order to run your programs are in the folder - [x] [!!Libraries for all the tutorials!!!](https://github.com/goxr3plus/Java-Speech-Recognizer-Tutorial--Calculator/tree/master/!!Libraries%20for%20all%20the%20tutorials!!!) + for tutorials 3 and 4 some extra libraries here - [x] [Tutorial 3,4 Plus Libraries](https://github.com/goxr3plus/Java-Speech-Recognizer-Tutorial--Calculator/tree/master/Tutorial%203%2C4%20Plus%20Libraries) #### ------>Calculator Program Tutorials - [x] Folder Name : **Tutorial1** This folder contains the first basic tutorial which contains a general class on how to use Sphinx4 . As simple as it . [![Java Speech Recognition](http://img.youtube.com/vi/R8vsXKFTee0/0.jpg)](https://www.youtube.com/watch?v=R8vsXKFTee0) > Update for Tutorial 1 September 2017 with Github Packages [![Java Speech Recognition](http://img.youtube.com/vi/NwnGJD6OWWQ/0.jpg)](https://www.youtube.com/watch?v=NwnGJD6OWWQ) - [x] Folder Name : **Tutorial2** This folder contains the first code for making the Speech Calculator vary basic. - [x] Folder Name : **Tutorial3** Continuation of the calculator program. - [x] Folder Name : **Tutorial4** Final part of the calculator program. #### ------>Using different Languages (Hindi , German , Italian etc) --Example below-- - [x] Folder Name : **Tutorial 1.1 Hindi LanguageTutorial** Contains **Tutorial1** folder code , and packages for Hindi Language Speech Recognition - [x] The same with the other folders starting with Tutorial 1.1 ....blah [![Java Speech Recognition](http://img.youtube.com/vi/7EGveeafVEw/0.jpg)](https://www.youtube.com/watch?v=7EGveeafVEw) #### ------>Speech Recognition + JavaFX - [x] Folder Name : **!!New Specific Tutorial For JavaFX!!** This folder contains the same code as **Tutorial1** + it is a JavaFX Application with User Interface . > Youtube Tutorial for JavaFX Speech Recognition Program + Sphinx4-5 [![Java Speech Recognition](http://img.youtube.com/vi/q19_3i4Z_Cs/0.jpg)](https://www.youtube.com/watch?v=q19_3i4Z_Cs) --- > Finally ![Java Speech Recognition](https://github.com/goxr3plus/Java-Speech-Recognizer-Tutorial--Calculator/blob/master/ScreenShot10312.png) ![Java Speech Recognition](https://github.com/goxr3plus/Java-Speech-Recognizer-Tutorial--Calculator/blob/master/ScreenShot43302.png)
0
integeruser/jgltut
Learning Modern 3D Graphics Programming with LWJGL 3 and JOML
3d-graphics java joml lwjgl3 tutorials
# Learning Modern 3D Graphics Programming with LWJGL 3 and JOML This project is a port of *[Learning Modern 3D Graphics Programming](https://paroj.github.io/gltut/)* tutorials to Java using [LWJGL](https://www.lwjgl.org/) and [JOML](http://joml-ci.github.io/JOML/). The original project, named `gltut`, can be found [here](https://github.com/paroj/gltut). Since it is needed by the tutorials, this repository also includes a partial port of the *[Unofficial OpenGL SDK](https://glsdk.sourceforge.net/docs/html/index.html)*, named `glsdk`, which contains a DDS texture loader and other useful stuff. To suggest a feature, report bugs or general discussion use the [issue tracker](https://github.com/integeruser/jgltut/issues). Contributions are welcome! :smile: ## Usage To set up the project, just import the supplied Maven POM into your favorite IDE and you are done. The code was last tested on: - Java SE Development Kit 8 - [LWJGL 3.1.2 build 29](https://www.lwjgl.org/download) - [JOML 1.9.3](https://github.com/JOML-CI/JOML/releases/tag/1.9.3) To play with the tutorials, run the `main` method of `integeruser.jgltut.TutorialChooser.java` and select the tutorial to run. To quit any tutorial simply press `ESC`. **Note for Mac OS users**: SWT applications on Mac OS require the JVM option `-XstartOnFirstThread`. Because of this, `TutorialChooser` cannot work on Mac OS. ## Notes I decided to keep the ported code as similar as possible to the original C++ code, and therefore variables and functions are almost identical to their counterpart in the original projects. The only notable difference is the introduction of the `commons` package to collect some classes used in several parts of the project. I also decided to keep the same directory layout: ``` jglsdk/ |-- glimg/ |-- glutil/ jgltut/ |-- commons/ |-- data/ |-- framework/ |-- tut01/ |------ Tut1.java |-- tut02/ |------ data/ |------ FragPosition.java |------ VertexColor.java |-- ... |-- ... |-- ... |-- tut17/ |------ data/ |------ CubePointLight.java |------ DoubleProjection.java |------ ProjectedLight.java |-- Tutorial.java |-- TutorialChooser.java ``` ## Credits The LWJGL license can be found [here](http://lwjgl.org/license.php). The JOML license can be found [here](https://github.com/JOML-CI/JOML/blob/master/LICENSE). Extract from the `gltut` license: > The following files are copywritten and distributed under the Creative Commons Attribution 3.0 Unported (CC BY 3.0) license, as described in the "./CC BY 3.0 legalcode.txt" file. Attribution for these works is presented here: > > Attributed to Etory, of OpenGameArt.org: > * data/seamless_rock1_small.dds > > Attributed to p0ss, of OpenGameArt.org: > * data/concrete649_small.dds > * data/dsc_1621_small.dds > * data/rough645_small.dds
0
mikadomethod/kata-java
The Kata used in our presentations and tutorials.
null
Kata in java ============ ##### Background Follow instructions in REPOROOT/kata.pdf ##### Goal New deliverable for Stranger Eons Ltd.
0
kelasterbuka/JAVA_Lanjut_OOP
repository tutorial channel youtube kelas terbuka topik OOP
null
# JAVA_Lanjut_OOP repository tutorial channel youtube kelas terbuka topik OOP
1
noidsirius/SootTutorial
A step-by-step tutorial for Soot (a Java static analysis framework)
java soot static-analysis tutorial visualization
# Soot Tutorial [![Build Status](https://travis-ci.com/noidsirius/SootTutorial.svg?branch=master)](https://travis-ci.com/noidsirius/SootTutorial) [![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/noidsirius/SootTutorial) [![Docker Pull](https://img.shields.io/docker/pulls/noidsirius/soot_tutorial)](https://hub.docker.com/r/noidsirius/soot_tutorial) This repository contains (will contain) several simple examples of static program analysis in Java using [Soot](https://github.com/Sable/soot). ## Who this tutorial is for? Anybody who knows Java programming and wants to do some static analysis in practice but does not know anything about Soot and static analysis in theory. If you have some prior knowledge about static program analysis I suggest you learn Soot from [here](https://github.com/Sable/soot/wiki/Tutorials). ### [Why another tutorial for Soot?](docs/Other/Motivation.md) ## Setup In short, use Java 8 and run `./gradlew build`. For more information and Docker setup, follow this [link](docs/Setup/). ## Chapters ### 1: Get your hands dirty In this chapter, you will visit a very simple code example to be familiar with Soot essential data structures and **Jimple**, Soot's principle intermediate representation. * `./gradlew run --args="HelloSoot"`: The Jimple representation of the [printFizzBuzz](demo/HelloSoot/FizzBuzz.java) method alongside the branch statement. * `./gradlew run --args="HelloSoot draw"`: The visualization of the [printFizzBuzz](demo/HelloSoot/FizzBuzz.java) control-flow graph. |Title |Tutorial | Soot Code | Example Input | | :---: |:-------------: |:-------------:| :-----:| |Hello Soot |[Doc](docs/1/) | [HelloSoot.java](src/main/java/dev/navids/soottutorial/hellosoot/HelloSoot.java) | [FizzBuzz.java](demo/HelloSoot/FizzBuzz.java) | <img src="docs/1/images/cfg.png" alt="Control Flow Graph" width="400"/> ### 2: Know the basic APIs In this chapter, you get familiar with some basic but useful methods in Soot to help read, analyze, and even update java code. * `./gradlew run --args="BasicAPI"`: Analyze the class [Circle](demo/BasicAPI/Circle.java). * `./gradlew run --args="BasicAPI draw"`: Analyze the class [Circle](demo/BasicAPI/Circle.java) and draws the call graph. |Title |Tutorial | Soot Code | Example Input | | :---: |:-------------: |:-------------:| :-----:| |Basic API |[Doc](https://medium.com/@noidsirius/know-the-basic-tools-in-soot-18f394318a9c)| [BasicAPI.java](src/main/java/dev/navids/soottutorial/basicapi/BasicAPI.java) | [Circle](demo/BasicAPI/Circle.java) | <img src="docs/2/images/callgraph.png" alt="Call Graph" width="400"/> ### 3: Android Instrumentation In this chapter, you learn how to insert code into Android apps (without having their source code) using Soot. To run the code, you need Android SDK (check this [link](docs/Setup/)). * `./gradlew run --args="AndroidLogger"`: Insert logging method calls at the beginning of APK methods of [Numix Calculator](demo/Android/calc.apk). * `./gradlew run --args="AndroidClassInjector"`: Create a new class from scratch and inject it to the [Numix Calculator](demo/Android/calc.apk). The instrumented APK is located in `demo/Android/Instrumented`. You need to sign it in order to install on an Android device: ```sh cd ./demo/Android # on Windows, replace 'sign.sh' by 'sign.ps1' ./sign.sh Instrumented/calc.apk key "android" adb install -r -t Instrumented/calc.apk ``` To see the logs, run `adb logcat | grep -e "<SOOT_TUTORIAL>"` |Title |Tutorial | Soot Code | Example APK| | :---: |:-------------: |:-------------:| :-----:| |Log method calls in an APK| [Doc](https://medium.com/@noidsirius/instrumenting-android-apps-with-soot-dd6f146ff4d2)| [AndroidLogger.java](src/main/java/dev/navids/soottutorial/android/AndroidLogger.java) | [Numix Calculator](demo/Android/calc.apk) (from [F-Droid](https://f-droid.org/en/packages/com.numix.calculator/))| |Create and inject a class into an APK| [Doc](https://medium.com/@noidsirius/instrumenting-android-apps-with-soot-dd6f146ff4d2) | [AndroidClassInjector.java](src/main/java/dev/navids/soottutorial/android/AndroidClassInjector.java) | [Numix Calculator](demo/Android/calc.apk) (from [F-Droid](https://f-droid.org/en/packages/com.numix.calculator/))| <img src="docs/3/images/packs.png" alt="Soot Packs + Dexpler" width="400"/> ### 4: Call graphs and PointsTo Analysis in Android This chapter gives you a brief overview o call graphs and PointsTo analysis in Android and you learn how to create calls graphs using FlowDroid. The source code of the example code is [here](demo/Android/STDemoApp). To run the code, you need Android SDK (check this [link](docs/Setup/)). * `./gradlew run --args="AndroidCallGraph <CG_Algorithm> (draw)"`: Create the call graph of [SootTutorial Demo App](demo/Android/st_demo.apk) using `<CG_Algorithm>` algorithm and print information such as reachable methods or the number of edges. * `<CG_Algorithm>` can be `SPARK` or `CHA` * `draw` argument is optional, if provided a visualization of call graph will shown. * For example, `./gradlew run --args="AndroidCallGraph SPARK draw"` visualizes the call graph generated by SPARK algorithm. * `./gradlew run --args="AndroidPTA"`: Perform PointsTo and Alias Analysis on [SootTutorial Demo App](demo/Android/st_demo.apk) using FlowDroid. |Title |Tutorial | Soot Code | Example APK| | :---: |:-------------: |:-------------:| :-----:| |Call graphs in Android| [Doc](https://medium.com/geekculture/generating-call-graphs-in-android-using-flowdroid-pointsto-analysis-7b2e296e6697)| [AndroidCallgraph.java](src/main/java/dev/navids/soottutorial/android/AndroidCallgraph.java) | [SootTutorial Demo App](demo/Android/st_demo.apk) ([source code](demo/Android/STDemoApp))| |PointsTo Analysis in Android| [Doc](https://medium.com/geekculture/generating-call-graphs-in-android-using-flowdroid-pointsto-analysis-7b2e296e6697)| [AndroidPointsToAnalysis.java](src/main/java/dev/navids/soottutorial/android/AndroidPointsToAnalysis.java) | [SootTutorial Demo App](demo/Android/st_demo.apk) ([source code](demo/Android/STDemoApp))| <img src="docs/4/images/Spark_CG.png" alt="The call graph of SootTutorial Demo app" width="400"/> ### 5: Some *Real* Static Analysis (:construction: WIP) * `./gradlew run --args="UsageFinder 'void println(java.lang.String)' 'java.io.PrintStream"`: Find usages of the method with the given subsignature in all methods of [UsageExample.java](demo/IntraAnalysis/UsageExample.java). * `./gradlew run --args="UsageFinder 'void println(java.lang.String)' 'java.io.PrintStream"`: Find usages of the method with the given subsignature of the given class signature in all methods of [UsageExample.java](demo/IntraAnalysis/UsageExample.java). |Title |Tutorial | Soot Code | Example Input | | :---: |:-------------: |:-------------:| :-----:| |Find usages of a method| | [UsageFinder.java](src/main/java/dev/navids/soottutorial/intraanalysis/usagefinder/UsageFinder.java) | [UsageExample.java](demo/IntraAnalysis/usagefinder/UsageExample.java) | |Null Pointer Analysis ||[NullPointerAnalysis](src/main/java/dev/navids/soottutorial/intraanalysis/npanalysis/) | [NullPointerExample.java](demo/IntraAnalysis/NullPointerExample.java) | ### 6: Interprocedural analysis (:construction: WIP) |Title |Tutorial | Soot Code | Example Input | | :---: |:-------------: |:-------------:| :-----:| | | | | |
1
egold555/Minecraft-1.8.8-PVP-Client-Series
Assets for my tutorial series
null
# Minecraft-1.8.8-PVP-Client-Files Files for my Youtube Series on coding a Minecraft 1.8.8 PVP Client. ## Series Info * Playlist: https://www.youtube.com/playlist?list=PLxbv-Ej1VQMQS9M2qnmEQtp-qL3xcA4ua * Discord Server: https://discord.gg/M3PAyyy
1
phu004/Java_tutorials
null
null
null
0
DSA-Marathon/DSA_Marathon
A full-fledged DSA marathon from 0 to 100. An initiative by GFG IIST Chapter and CodeChef IIST Chapter.
cpp dsa java problem-solving tutorials
<p align = 'center'> <a href='https://linktr.ee/dsa_marathon'> <img src = "https://img.shields.io/badge/DSA_MARATHON-4B275F?style=round" width = '50%'/></a> </p> <div align = "center"> <a href='https://linktr.ee/dsa_marathon'> <img align="center" width="90%" src="Images/logo.jpg" alt=""></a> <br> <p> <b>Full fledged DSA Marathon from Zero to Hundred. Enhance Your Data Structure and Algorithm knowledge with us. A Collaboration Event Series by GFG IIST Chapter and CodeChef IIST Chapter </b> </p> </div> - [Registration Form](https://docs.google.com/forms/d/e/1FAIpQLSeSWXG04wekDV13L_nrPYsMSdRyhbCcRsWQkzdfNg_iTSHc_w/viewform) - [Syllabus](Syllabus.md) - [Faqs](faqs.md) <!-- - [Code of Conduct](Code_of_Conduct.md) --> <!-- - [How to get started](Get_Stated.md) --> ### Topics - [Git and Github](/Git_and_Github) - [Basic Language Questions](/Basic_language_ques) - [Time and Space Complexity](/Time_and_Space_Complexity) - [Array](/Array) - [Searching and Sorting](/Searching_and_Sorting) - [Mathematics and Bit Manipulation](/Mathematics) ## Follow for More Update <h2 align='center'><a href='https://linktr.ee/dsa_marathon'> DSA MARATHON </a></h2> <h3 align='center'> &nbsp;&nbsp;@CodeIISTChapter &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @GFGIISTChapter</h3> <p align = 'center'>&nbsp;&nbsp;&nbsp; <a href="https://www.instagram.com/codechef_iist_chapter/"> <img align="center" width="50px" src="https://github.com/edent/SuperTinyIcons/blob/master/images/svg/instagram.svg" /> </a>&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://www.linkedin.com/company/codechef-iist-chapter/"> <img align="center" width="50px" src="https://github.com/edent/SuperTinyIcons/blob/master/images/svg/linkedin.svg" /> </a>&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://twitter.com/ChapterIist"> <img align="center" width="50px" src="https://github.com/edent/SuperTinyIcons/blob/master/images/svg/twitter.svg" /> </a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://www.instagram.com/gfg_iist_chapter/"> <img align="center" width="50px" src="https://github.com/edent/SuperTinyIcons/blob/master/images/svg/instagram.svg" /> </a>&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://www.linkedin.com/company/geeksforgeeks-iist/"> <img align="center" width="50px" src="https://github.com/edent/SuperTinyIcons/blob/master/images/svg/linkedin.svg" /> </a>&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://twitter.com/GFGIISTChapter"> <img align="center" width="50px" src="https://github.com/edent/SuperTinyIcons/blob/master/images/svg/twitter.svg" /> </a> </p> ### All amazing members of these series --> <table> <tr> <td> <a href="https://github.com/geeky01adarsh/DSA-Marathon/graphs/contributors"> <img src="https://contributors-img.web.app/image?repo=geeky01adarsh/DSA-Marathon" /> </a> </a> </td> </tr> </table> <hr> <h1 align=center> Happy Coding 👨‍💻 </h1> This program is now over. Thank you for your support.
0
SilverTiger/lwjgl3-tutorial
Tutorial for the Lightweight Java Game Library (LWJGL) 3
glfw java lwjgl lwjgl3 opengl tutorial
# Lightweight Java Game Library 3 Tutorial This tutorial is for anyone who wants to get started with the new version of the [Lightweight Java Game Library](http://www.lwjgl.org/). In the course of the tutorial we will use OpenGL 3.2 Core Profile for creating a small game with shaders. For older hardware there will possibly be an OpenGL 2.1 version available. For a table of contents you can look into the [wiki of this repository](https://github.com/SilverTiger/lwjgl3-tutorial/wiki).
1
in28minutes/JavaTutorialForBeginners
Java Tutorial for Beginners with examples
java java-8
# Title of the Best Course in the world ## Caption for the course. * [Installing Eclipse, Maven and Java](#installing-tools) * [Running Examples](#running-examples) * [Course Overview](#course-overview) - [Course Steps](#step-list) - [Expectations](#expectations) * [About in28Minutes](#about-in28minutes) - [Our Beliefs](#our-beliefs) - [Our Approach](#our-approach) - [Find Us](#useful-links) - [Other Courses](#other-courses) ## Getting Started - Eclipse - https://courses.in28minutes.com/p/eclipse-tutorial-for-beginners - Maven - https://courses.in28minutes.com/p/maven-tutorial-for-beginners-in-5-steps - JUnit - https://courses.in28minutes.com/p/junit-tutorial-for-beginners - Mockito - https://courses.in28minutes.com/p/mockito-for-beginner-in-5-steps ## Installing Tools - PDF : https://github.com/in28minutes/SpringIn28Minutes/blob/master/InstallationGuide-JavaEclipseAndMaven_v2.pdf - Video : https://www.youtube.com/playlist?list=PLBBog2r6uMCSmMVTW_QmDLyASBvovyAO3 - GIT Repository : https://github.com/in28minutes/getting-started-in-5-steps ## Running Examples - Download the zip or clone the Git repository. - Unzip the zip file (if you downloaded one) - Open Command Prompt and Change directory (cd) to folder containing pom.xml - Installation Video : https://www.youtube.com/playlist?list=PLBBog2r6uMCSmMVTW_QmDLyASBvovyAO3 - For help : use our installation guide - https://github.com/in28minutes/SpringIn28Minutes/blob/master/InstallationGuide-JavaEclipseAndMaven_v2.pdf ## Course Overview - I'm Ranga Karanam. I've so and so much experience with ... - In this course, You will learn the *** Framework step by step with (*** functionality) using (*** framework features) - You will learn the basics like *** and move on to the advanced concepts like ***. - You will use - ... todo ... - Maven for dependency management, building and running the application in tomcat. - Eclipse IDE. ### Introduction Developing your first application with XYZ Framework is fun. Introduction to XYZ Framework.. In this course, you will learn the basics developing a Basic Todo Management Application using XYZ Framework. You will build the application step by step - in more than 25 steps. This course would be a perfect first step as an introduction to XYZ Framework. You will be using Spring (Dependency Management), Spring MVC, Spring Boot, Spring Security (Authentication and Authorization), BootStrap (Styling Pages), Maven (dependencies management), Eclipse (IDE) and Tomcat Embedded Web Server. We will help you set up each one of these. You will learn about - Topic No 1 - Topic No 1 - Topic No 1 - Topic No 1 - Topic No 1 ### Step Wise Details - Step 01: Learn to Dance - Step 02: - Step 03: - Step 04: - Step 05: - Step 06: - Step 07: - Step 08: - Step 09: - Step 10: - Step 11: - Step 12: - Step 13: - Step 14: - Step 15: - Step 16: - Step 17: - Step 18: - Step 19: - Step 20: - Step 21: - Step 22: - Step 23: - Step 24: - Step 25: ### Expectations - You should know ***. - You should know ***. - You are NOT expected to have any experience with Eclipse,Maven or Tomcat. - We will help you install Eclipse and get up and running with Maven and Tomcat. ## Let's have some fun - What are we waiting for? - Let's have some fun with *** in 25 Steps. - I had fun creating this course and hope you would too. - Thanks for your interest in Our Course - I hope you’re as excited as I am! - If you’re ready to learn more and sign up for the course, - go ahead and hit that Enroll button, - or take a test drive by using the Free Preview feature. - See you in the course! ## Exercises - TODO ## Future Things To Do - TODO ## Conclusion - Thats a lot of ground you have covered over the last so and so.. - To find out more about *** use these References - I had fun creating this course and I'm sure you had some fun too. - Good Luck and Bye from the team here at in28Minutes - Do not forget to leave us a review. ## About in28Minutes At in28Minutes, we ask ourselves one question everyday > How do we create more amazing course experiences? > We use 80-20 Rule. We discuss 20% things used 80% of time in depth. We are creating amazing learning experiences for learning Spring Boot with AWS, Azure, GCP, Docker, Kubernetes and Full Stack. 300,000 Learners rely on our expertise. [Find out more.... ](https://github.com/in28minutes/learn#best-selling-courses) ![in28MinutesLearningRoadmap-July2019.png](https://github.com/in28minutes/in28Minutes-Course-Roadmap/raw/master/in28MinutesLearningRoadmap-July2019.png)
1
wetw0rk/AWAE-PREP
This repository will serve as the master" repo containing all trainings and tutorials done in preperation for OSWE in conjunction with the AWAE course. This repo will likely contain custom code by me and various courses."
null
# AWAE PREP Layout This repository will serve as the "master" repo containing all trainings and tutorials done in preparation for OSWE in conjunction with the AWAE course. This repo will likely contain custom code by me and various courses. Below you can see in what order I completed these challenges / courses. ## Prep Breakdown The following table shows notes, courses, challenges, and tutorials taken in preparation for the AWAE. | Order | Name | Type | Link | |--- | --- | --- | --- | | 1 | JavaScript For Pentesters | Course | https://www.pentesteracademy.com/course?id=11 | | 2 | Edabit (Javascript, Java, PHP) | Challenges | https://edabit.com/ | | 3 | Simple Object Oriented Language Examples | Notes | N/A (I just wrote simple templates) | 4 | From SQL Injection to Shell | Tutorial | https://pentesterlab.com/exercises/from_sqli_to_shell/ | | 5 | XSS and MySQL | Challenge | https://www.vulnhub.com/entry/pentester-lab-xss-and-mysql-file,66/ | | 6 | Understanding PHP Object Injection | Tutorial | https://securitycafe.ro/2015/01/05/understanding-php-object-injection/ | | 7 | /dev/random: Pipe | Challenge | https://www.vulnhub.com/entry/devrandom-pipe,124/ | | 8 | Understanding Java Deserialization | Tutorial | https://nytrosecurity.com/2018/05/30/understanding-java-deserialization/ | 9 | Practicing Java Deserialization Exploits | Challenge/Tutorial | https://diablohorn.com/2017/09/09/understanding-practicing-java-deserialization-exploits/ | | 10 | SQL Injection Attacks and Defense | Book | https://www.amazon.com/Injection-Attacks-Defense-Justin-Clarke/dp/1597499633 | ## Post Prep Breakdown Having completed the course, below is everything done in regards to prep before the exam. If you have not taken the AWAE and are considering taking it definitely do everything shown above, and read the source! I have provided README's in each directory and source code so you can see what I did. I cannot share extra miles .... so those will not be within the repository. Best of luck! - Complete all extra miles! I know some are harder than others but push through (one took me 8 days alone). - Be comfortable using every debugger shown within the course. - Understand Object Oriented Languages taught throughout the course. No need to be a master in each language, but be able to code something fast using existing libs. - Be comfortable crafting a full POC (as done throughout the entire course) - Look for vulnerabilities ;) This may not seem like much, but it's what I did for prep. My best advice is DO NOT OVERTHINK things and don't rush through it. It took me 2 attempts when it should have taken one, I was jumping around not documenting enough what I was trying (It's easy to create your own rabbit holes...). Slow down you have 48 hours! ## Community Contributions & Enhancements If you find a new tutorial, challenge, or improve one of the exploits/payloads feel free to submit a pull request! Since Offsec has recently updated the course I may take it at a later date and upload some new challenges myself. The main things I ask when contributing any challenges or tutorials is: 1. All challenges/tutorials MUST be hands on - no exceptions. If its something where you just look at code snippets try to make it interactive. Re-code the samples and simulate them etc. 2. You yourself must have the challenge completed. This means working through it and having code samples ready to submit. 3. ALL submissions must follow the same structure as the main repository. Meaning: - Its own directory - A README.md containing: - A header describing the submission (e.g XSS and MySQL - NO SQLMAP ALLOWED) along with a description of the challenge. - A personal note to either help the challenger or point them in the right direction. - Links, always credit the original authors! - Code Samples, Working Exploit Code, Working Payloads! I don't wanna hear about the theory of a universal bypass I wanna see it in code! - NO WEBM submissions. I don't trust some of you haha, YouTube links are fine though. For your own safety I recommend adding a header like this to all your code: ```python #/usr/bin/env python # # Exploit Title : Practicing Java Deserialization Exploits # Author : wetw0rk # Vulnerable Software : https://github.com/NickstaDB/DeserLab # # Usage : DeserLab is an intentionally vulnerable server that # is vulnerable to java deserialization. This exploit # leverages the vulnerability within the application. # ``` Just to be sure you get as much credit as you deserve.
0
CodingAP/lwjgl3-tutorial
New Tutorial
null
# lwjgl3-tutorial New Tutorial
1
KriechelD/YouTubeChannel
Here you can find the source code to my tutorials on YouTube: https://www.youtube.com/DennisKriechel
null
null
0
antoniolg/LimeApp
Open source Application based on the tutorials written in http://www.limecreativelabs.com. The best way to quickly test tutorial result.
null
LiME Creative Labs ================= <a href="https://play.google.com/store/apps/details?id=com.limecreativelabs.app"> <img alt="Android app on Google Play" src="https://developer.android.com/images/brand/en_app_rgb_wo_45.png" /> </a> LiME is an Android App based on its [homonymous blog][5]. It was created to show live demos of tutorials created on the blog. This App is basically a visual quick helper to detect tutorials you may be interested in and easily find its implementation. Main Activity contains a link to the [blog][5] and to this page. Each tutorial also has a link to its written version. LiME Creative Labs blog is written in Spanish, but is easy to understand using a tool like Google Translate. If you don't like this option, source code is well documented an organized. A package has been created for each tutorial, so the code is isolated. This App will be updated on every new tutorial added. What you can currently find: * __Sliding Pane Layout__: An example of SlidingPaneLayout implementation, another new layout from Support Library r13. * __Drawer Layout__: An example of Drawer Layout implementation, optimized to be used with ActionBarSherlock. * __Action Bar Refresh__: when the user clicks the Refresh Button, an indeterminate <tt>ProgressBar</tt> is shown until the operation is performed. * __Test connectivity status live__: A broadcast receiver intercepts connectivity changes and updates the UI. * __Action Bar Search__: A search action lets the user search for something by showing a textbox on Action Bar. * __Multiple selection in ListView using ActionBarSherlock__: Implementation of multiple selection using a SelectionAdapter. ![Example Image][1] Building the project ------------------------- It is recommended to use maven to compile this project. Download the project and import to your IDE as a maven project. You will need to add [listviewanimations][2] jar to your local maven repository. If you are on a Unix shell, just run the provided `installDependencies.sh` script. If you want to use it as a regular Android project, go to the dependencies section and download those projects as libraries or jars to the build path. Dependencies -------------------- * [ActionBarSherlock][3] by Jake Wharton. * [Gson][4] * [ListViewAnimations][2] by Niek Haarman Developed By -------------------- Antonio Leiva Gordillo - <antonioleivag@gmail.com> <a href="http://twitter.com/lime_cl"> <img alt="Follow me on Twitter" src="https://raw.github.com/antoniolg/LimeApp/master/art/social/twitter.jpg" /> </a> <a href="https://plus.google.com/107221928564556085738"> <img alt="Follow me on Google+" src="https://raw.github.com/antoniolg/LimeApp/master/art/social/google-plus.jpg" /> </a> <a href="http://es.linkedin.com/in/antoniolg"> <img alt="Follow me on LinkedIn" src="https://raw.github.com/antoniolg/LimeApp/master/art/social/linked-in.jpg" /> License ----------- Copyright 2013 Antonio Leiva Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. [1]: https://raw.github.com/antoniolg/LimeApp/master/art/screenshots.png [2]: https://github.com/nhaarman/ListViewAnimations [3]: https://www.actionbarsherlock.com [4]: https://code.google.com/p/google-gson/ [5]: http://www.limecreativelabs.com/?utm_source=main&utm_medium=readme&utm_campaign=github
1
Watson-Explorer/wex-wdc-integration-samples
Sample code and tutorials for integrating Watson Explorer with Watson Developer Cloud services on Bluemix
null
All future sample code, including updates to the samples originall provided here, are maintained in the [IBM Watson repos on GitHub](https://github.com/ibm-watson). This includes the following repositories of interest, originally from this project: * [WEX Application Builder Samples](https://github.com/IBM-Watson/wex-appbuilder-samples) * [WEX with Personality Insights Example](https://github.com/IBM-Watson/wex-appbuilder-samples/tree/master/personality_insights) * [Application Builder Sample Proxy](https://github.com/IBM-Watson/wex-appbuilder-sample-proxy) * [And many other interesting Watson Explorer samples, examples, and applications](https://github.com/ibm-watson?utf8=%E2%9C%93&query=wex) For help getting started with using [Watson Explorer and Bluemix, there is an introduction guide available](https://github.com/IBM-Watson/wex-appbuilder-samples/blob/master/intro-to-bluemix-for-app-builder.md). ## Licensing All sample code contained within this project repository or any subdirectories is licensed according to the terms of the MIT license, which can be viewed in the file license.txt. ## Open Source @ IBM [Find more open source projects on the IBM Github Page](http://ibm.github.io/)
1
lankydan/spring-boot-hateoas
Tutorial on using spring boot hateoas
null
null
1
frank-lam/fullstack-tutorial
🚀 fullstack tutorial 2022,后台技术栈/架构师之路/全栈开发社区,春招/秋招/校招/面试
computer-science fullstack-developer interview java java-interview skill-tree
<div align="center"><img src="assets/logo-2021.svg" width="80%"/></div><br/> | I | II | III | IV | V | VI | VII | VIII | IX | X | XI | XII | | :--------------------------: | :-------------------: | :----------------------: | :---------------------: | :--------------: | :---------------: | :----------------------: | :----------------------: | :----------------------: | :----------------------: | :----------------------: | :----------------------: | | 算法<br />[📝](#一数据结构与算法) | Java<br/>[☕️](#二java) | Python<br />[🐍](#三python) | 前端<br />[🔗](#四前端) | 数据库<br/>[💾](#五数据库) | 操作系统<br/>[💻](#六操作系统) | 网络通信<br/>[☁️](#七网络通信) | 分布式<br/>[📃](#八分布式) | 机器学习<br/> [🔍](#九机器学习) |工具<br/>[🔨](#十工具) |Learn<br />[📖](#learn-) |Talking<br />[💡](#talking-bulb) | <div align="center"> <p> ✨✨✨ </p> <p> 和 500+ 技术达人在线交流: <a href="notes/技术交流群.md">🤟 快来吧,和大家一起技术互动交流</a> </p> <p> 『技术博客』:<a href="https://www.frankfeekr.cn">www.frankfeekr.cn</a> | 『开源贡献』:<a href="notes/开源贡献.md">⊱ 英雄招募令</a> | 『微信订阅号』:全栈开发社区 </p> </div> <div align="center"><img src="assets/zhishixingqiu.JPG" width="40%"/></div><br/> 🔥🔥🔥 欢迎光临 LinTools 开发者的在线导航: https://tools.frankfeekr.cn 如果你有更好的在线工具,[请点击留言](https://github.com/frank-lam/fullstack-tutorial/issues/65),持续更新! ## 前言 - [谈谈技术学习的一些方法论](https://www.frankfeekr.cn/2019/05/09/谈谈技术学习的一些方法论/) 在学习技术这条路上并不是一帆风顺,也一直在探索一条适合自己的学习方法。从一开始的技术小白,到现在还比较上道的老鸟,在这个过程中走了太多的弯路,想在这里和大家分享一些我的经历和学习方法。 - [如何选择自己的技术栈](https://www.frankfeekr.cn/2019/05/27/如何选择自己的技术栈/) 在编程的世界里,该如何选择自己的技术栈呢。学前端?学 APP 开发?对于 Java、C++、C#、Python、PHP 又如何选择呢?人工智能现如今这么火,是不是机器学习、深度学习更高级一些呢?那么程序员又如何修炼内功呢? - [全栈开发神兵利器](notes/全栈开发神兵利器.md) 工欲善其事,必先利其器。这里我将推荐开发过程中的提效工具、开发利器、协作工具、文档技术等等。 - [XP 极限编程](notes/XP极限编程.md) 敏捷软件开发中可能是最富有成效的几种方法学之一 ## 技能图谱 - [backend skill](notes/SkillTree/backend-skill.md) 后台开发技能图谱,从程序员的内功修炼到后台语言,分布式系统架构 ## 一、数据结构与算法 - [数据结构与算法](notes/数据结构与算法.md)   排序算法、动态规划、递归、回溯法、贪心算法等 - [海量数据处理](notes/海量数据处理.md) 数据处理典型案例,逐渐更新 ## 二、Java - [Java 基础概念](notes/JavaArchitecture/01-Java基础.md)   基本概念、面向对象、关键字、基本数据类型与运算、字符串与数组、异常处理、Object 通用方法 - [Java 集合框架](notes/JavaArchitecture/02-Java集合框架.md)   数据结构 & 源码分析:ArrayList、Vector、LinkedList、HashMap、ConcurrentHashMap、HashSet、LinkedHashSet and LinkedHashMap - [Java 并发编程](notes/JavaArchitecture/03-Java并发编程.md)   线程状态、线程机制、线程通信、J.U.C 组件、JMM、线程安全、锁优化 - [Java I/O](notes/JavaArchitecture/04-Java-IO.md)   磁盘操作、字节操作、字符操作、对象操作、网络操作、NIO - [Java 虚拟机](notes/JavaArchitecture/05-Java虚拟机.md)   运行时数据区域、垃圾收集、内存分配机制、类加载机制、性能调优监控工具 - [Java 设计模式](notes/JavaArchitecture/06-Java设计模式.md)   Java 常见的 10 余种设计模式,全 23 种设计模式逐步更新 - [Java Web](notes/JavaArchitecture/07-JavaWeb.md)   包含 Servlet & JSP、Spring、SpringMVC、Mybatis、Hibernate、Structs2 核心思想,如 IOC、AOP 等思想。SSM 更详细请转向:[Spring](notes/JavaWeb/Spring.md) | [SpringMVC](https://github.com/frank-lam/SpringMVC_MyBatis_Learning) | [MyBatis](https://github.com/frank-lam/SpringMVC_MyBatis_Learning) ## 三、Python - [Python 语言基础](notes/Python/Python简介及基础语法.md) ## 四、前端 - [前端知识体系](notes/Frontend/前端知识体系.md) - [Angular 基础知识](notes/Frontend/Angular.md) - [ES6+ 语法全解析](https://notes.frankfeekr.cn/docs/frontend/es6/%E9%A1%B9%E7%9B%AE%E5%87%86%E5%A4%87/%E5%89%8D%E8%A8%80) <details> <summary>TODO LIST</summary> - HTML5 - CSS3 - CSS 预处理 - sass(scss) - less - stylus - CSS 框架 - BootStarp - LayUI - JavaScript 基础语法、进阶、ES6 - JavaScript 框架 - Vue - React - Angular - jQuery - Node 常用 api、对象池、异常处理、进程通信、高并发 - 静态类型检查 - TypeScript - Flow - 构建/打包工具 - webpack - gulp - rollup - 包管理工具 - npm - yarn - 服务端渲染 - koa2 - express - nuxt - next </details> ## 五、数据库 - [MySQL](notes/MySQL.md) 存储引擎、事务隔离级别、索引、主从复制 - [Redis](notes/Redis.md) Redis 核心知识 - [SQL](notes/SQL.md) 常用 SQL 语句 - [PostgreSQL](notes/PostgreSQL.md) 一个开源的关系数据库,是从伯克利写的 POSTGRES 软件包发展而来的 - [InfluxDB](https://www.frankfeekr.cn/2019/07/24/influxdb-tutorial-start/) 玩转时序数据库 ## 六、操作系统 - [操作系统原理](notes/操作系统.md)   进程管理、死锁、内存管理、磁盘设备 - [Linux](notes/Linux.md)   基础核心概念、常用命令使用 ## 七、网络通信 - [计算机网络](notes/计算机网络.md)   传输层、应用层(HTTP)、网络层、网络安全 - [RESTful API](notes/RESTful%20API.md) 软件架构风格、格设计原则和约束条件 - [Web网络安全](notes/网络安全.md) web前后端漏洞分析与防御,XSS 攻击、CSRF 攻击、DDoS 攻击、SQL 注入 ## 八、分布式 - [Docker](notes/Docker基础.md) 容器化引擎服务 - [微服务](notes/微服务.md) 微服务简介、API 网关、服务注册发现、服务通信 - [Zookeeper](notes/分布式/Zookeeper.md) 分布式协调服务,服务注册发现 - [Kafka](notes/MicroService/kafka/README.md) 深入浅出 Kafka,将用最极简的语言带你走进 Kafka 的消息中间件世界 【说明】**分布式专题** 笔者也在学习中,这里列举了一些技能列表,笔者将局部更新。敬请期待 <details> <summary>TODO LIST</summary> - Kubernetes(k8s) 容器化部署,管理云平台中多个主机上的容器化的应用 - 云计算 SaaS(软件即服务) 、PaaS(平台即服务) 、IaaS(基础架构即服务) - Zookeeper 分布式协调服务,服务注册发现 - Dubbo、Thrift(RPC 框架) 分布式服务治理 - 分布式事务解决方案 - ActiveMQ、Kafka、RabbitMQ 分布式消息通信 - 熔断,限流,降级机制 - Redis 分布式缓存 - Mycat 数据库路由 - Nginx 反向代理 - Tomcat Web Server 服务 - DevOps 自动化运维,持续集成、持续交付、持续部署 - 分布式锁 基于 Redis、MySQL、Zookeeper 的分布式锁实现 - FastDFS 轻量级分布式文件管理系统 - Go 并发的、带垃圾回收的、快速编译的语言 </details> ## 九、机器学习 - [深度学习初识](notes/DeepLearning/深度学习初识.md) - 经典机器学习算法 K 近邻算法、线性回归、梯度下降法、逻辑回归、支持向量机、决策树、集成学习 ## 十、工具 - [Git](notes/git-tutorial.md) 学习指引,将用最极简的语言带你进入 Git 版本控制的世界 - [Git 工作流](notes/Git工作流.md) 集中式工作流,功能分支工作流, GitFlow 工作流,Forking 工作流,Pull Requests - [正则表达式](notes/正则表达式.md) 常见符号含义,速查表 - [手把手教你搭建内网穿透服务](https://github.com/frank-lam/lanproxy-nat) 基于 lanproxy 穿透服务,为你定了一键启动的服务端和客户端 Docker 镜像 - [基于 SpringBoot & IDEA & JRebel 玩转远程热部署与远程调试](https://www.frankfeekr.cn/2019/07/17/springboot-idea-jrebel-hotswap/) 手把手带你玩转,远程调试与远程热部署 - [什么是 TDD 及常见的测试方法](notes/软件测试.md) ## Learn 📖 - [LEARN_LIST](notes/LEARNLIST.md)   包含阅读清单,学习课程两部分 - [web应用开发标准流程](notes/web应用开发标准流程.md) ## Talking :bulb: 本仓库致力于成为一个全栈开发爱好者的学习指南,给初学者一个更明确的学习方向,同时也是对自己技能的强化和巩固。在架构师这条路上,希望和大家一起成长,帮助更多的计算机爱好者能够有一个明确的学习路径。持续不间断的维护本仓库,也欢迎有更多的极客们加入。 都说好记性不如烂笔头,定期的学习和整理必然对学习巩固有所帮助,这里通过索引的方式对全栈开发技术做一个系统分类,方便随时巩固和学习,当然还有面试。在学习这条路上难免会有很多盲点和学不完的知识。有道无术,术尚可求,掌握好思维能力才能应对千变万化的技术。不要把大脑当成硬盘,也不要做高速运转的 CPU,而修行自己的大脑成为一个搜索引擎,学会分析解决问题。 Since 20,May,2018 ## Reference 个人的能力有限,在编写的过程中引用了诸多优秀的 GitHub 仓库。本项目的启发来自 [@CyC2018](https://github.com/CyC2018) 的学习笔记,是一个非常优秀的开源项目,在本仓库中部分内容引用文字和图例;引用了 [@计算所的小鼠标](https://github.com/CarpenterLee) 中对于 JCF 的源码分析和理解;引用了 [阿里面试题总结](https://www.nowcoder.com/discuss/5949) 中全部的面试题,并对面经进行了整理勘误,并进行了知识拓展和修改;引用了 [牛客网](https://www.nowcoder.com) 上的面试经验贴。也引用了知乎上的热门回答和优秀博客的回答。在这里特别鸣谢,我将每篇文章中做外链引用说明。 文中我也推荐了学习的书籍和学习课程,都将附着上最高清、最形象的配图进行讲解。在文中的配图都来自自己绘制的、博客、Github、PDF书籍等等,这里没法一一感谢,谢谢你们。 推荐一些优秀的开源项目,供大家参考,[reference](notes/reference.md)。 ## Contributors Thank you to all the people who already contributed to fullstack-tutorial ! Please make sure to read the [Contributing Guide/如何给我的仓库贡献](notes/docs/如何给我的仓库贡献.md) before making a pull request. <a href="https://github.com/frank-lam/fullstack-tutorial/graphs/contributors"><img src="https://opencollective.com/fullstack-tutorial/contributors.svg?width=890&button=false" /></a> ## Stargazers over time ![Stargazers over time](https://starcharts.herokuapp.com/frank-lam/fullstack-tutorial.svg) ## License <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/"><img alt="知识共享许可协议" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png" /></a> Copyright (c) 2021-present, Frank Lam ## 关于作者 :boy: <div align="center"> <p> 『作者简介』:<a href="https://www.frankfeekr.cn/author">https://www.frankfeekr.cn/author</a> </p> </div> <div align="center"> <p> 在颠覆世界的同时,也要好好关照自己。 </p> <a target="_blank" href="https://frankfeekr.cn" rel="nofollow"><img src="https://img.shields.io/badge/BLOG-frankfeekr.cn-blue.svg" alt="BLOG" data-canonical-src="" style="max-width:100%;"></a> <a target="_blank" href="mailto:frank_lin@whu.edu.cn" rel="nofollow"><img src="https://img.shields.io/badge/Email-frank__lin@whu.edu.cn-lightgrey.svg" alt="邮箱" data-canonical-src="" style="max-width:100%;"></a> <a target="_blank" href="https://jq.qq.com/?_wv=1027&k=593WvX0" rel="nofollow" ><img src="https://img.shields.io/badge/QQ群-862619503-green.svg" alt="QQ群" data-canonical-src="" style="max-width:100%;"></a> <br/><br/> <p> from zero to hero. </p> </div> <div align="center"> <img src="assets/wechat/wx-green.png" width="70%"/></div>
1
in28minutes/TDDin28Minutes
TDD Tutorial For Beginners - from in28Minutes
null
# TDDin28Minutes Learn TDD from in28Minutes. Test Driven Development for Beginners ## Video Tutorial https://www.youtube.com/watch?v=QXo8bCv1BiQ ## Section 1 What is TDD What is TDD? ## Section 2 Basics of TDD ### Three Steps in TDD - RED - GREEN - REFACTOR ### Three Laws of TDD - New Code only on Red bar - Simplest code to make test fail - Simplest code to make test succeed ## Section 3  Playing with TDD - Example 1 - Example 2 ## Section 4  Continuing with TDD - A Quick Revision - Have Patience - Get a Mentor - Practice - Have Fun ## About in28Minutes At in28Minutes, we ask ourselves one question everyday > How do we create more amazing course experiences? > We use 80-20 Rule. We discuss 20% things used 80% of time in depth. We are creating amazing learning experiences for learning Spring Boot with AWS, Azure, GCP, Docker, Kubernetes and Full Stack. 300,000 Learners rely on our expertise. [Find out more.... ](https://github.com/in28minutes/learn#best-selling-courses) ![in28MinutesLearningRoadmap-July2019.png](https://github.com/in28minutes/in28Minutes-Course-Roadmap/raw/master/in28MinutesLearningRoadmap-July2019.png)
1
obviam/star-assault
The Star Assault code to accompany the tutorial
null
null
1
marcojakob/tutorial-javafx-8
Example Sources for JavaFX 8 Tutorial
null
# JavaFX 8 Tutorial - Sources These are example sources for the [JavaFX 8 Tutorial](http://code.makery.ch/java/javafx-8-tutorial-intro/).
1
opennetworkinglab/ngsdn-tutorial
Hands-on tutorial to learn the building blocks of the Next-Gen SDN architecture
gnmi onos openconfig p4 p4runtime stratum yang
# Next-Gen SDN Tutorial (Advanced) Welcome to the Next-Gen SDN tutorial! This tutorial is targeted at students and practitioners who want to learn about the building blocks of the next-generation SDN (NG-SDN) architecture, such as: * Data plane programming and control via P4 and P4Runtime * Configuration via YANG, OpenConfig, and gNMI * Stratum switch OS * ONOS SDN controller Tutorial sessions are organized around a sequence of hands-on exercises that show how to build a leaf-spine data center fabric based on IPv6, using P4, Stratum, and ONOS. Exercises assume an intermediate knowledge of the P4 language, and a basic knowledge of Java and Python. Participants will be provided with a starter P4 program and ONOS app implementation. Exercises will focus on concepts such as: * Using Stratum APIs (P4Runtime, gNMI, OpenConfig, gNOI) * Using ONOS with devices programmed with arbitrary P4 programs * Writing ONOS applications to provide the control plane logic (bridging, routing, ECMP, etc.) * Testing using bmv2 in Mininet * PTF-based P4 unit tests ## Basic vs. advanced version This tutorial comes in two versions: basic (`master` branch), and advanced (this branch). The basic version contains fewer exercises, and it does not assume prior knowledge of the P4 language. Instead, it provides a gentle introduction to it. Check the `master` branch of this repo if you're interested in the basic version. If you're interested in the advanced version, keep reading. ## Slides Tutorial slides are available online: <http://bit.ly/adv-ngsdn-tutorial-slides> These slides provide an introduction to the topics covered in the tutorial. We suggest you look at it before starting to work on the exercises. ## System requirements If you are taking this tutorial at an event organized by ONF, you should have received credentials to access the **ONF Cloud Tutorial Platform**, in which case you can skip this section. Keep reading if you are interested in working on the exercises on your laptop. To facilitate access to the tools required to complete this tutorial, we provide two options for you to choose from: 1. Download a pre-packaged VM with all included; **OR** 2. Manually install Docker and other dependencies. ### Option 1 - Download tutorial VM Use the following link to download the VM (4 GB): * <http://bit.ly/ngsdn-tutorial-ova> The VM is in .ova format and has been created using VirtualBox v5.2.32. To run the VM you can use any modern virtualization system, although we recommend using VirtualBox. For instructions on how to get VirtualBox and import the VM, use the following links: * <https://www.virtualbox.org/wiki/Downloads> * <https://docs.oracle.com/cd/E26217_01/E26796/html/qs-import-vm.html> Alternatively, you can use the scripts in [util/vm](util/vm) to build a VM on your machine using Vagrant. **Recommended VM configuration:** The current configuration of the VM is 4 GB of RAM and 4 core CPU. These are the recommended minimum system requirements to complete the exercises. When imported, the VM takes approx. 8 GB of HDD space. For a smooth experience, we recommend running the VM on a host system that has at least the double of resources. **VM user credentials:** Use credentials `sdn`/`rocks` to log in the Ubuntu system. ### Option 2 - Manually install Docker and other dependencies All exercises can be executed by installing the following dependencies: * Docker v1.13.0+ (with docker-compose) * make * Python 3 * Bash-like Unix shell * Wireshark (optional) **Note for Windows users**: all scripts have been tested on macOS and Ubuntu. Although we think they should work on Windows, we have not tested it. For this reason, we advise Windows users to prefer Option 1. ## Get this repo or pull latest changes To work on the exercises you will need to clone this repo: cd ~ git clone -b advanced https://github.com/opennetworkinglab/ngsdn-tutorial If the `ngsdn-tutorial` directory is already present, make sure to update its content: cd ~/ngsdn-tutorial git pull origin advanced ## Download / upgrade dependencies The VM may have shipped with an older version of the dependencies than we would like to use for the exercises. You can upgrade to the latest version using the following command: cd ~/ngsdn-tutorial make deps This command will download all necessary Docker images (~1.5 GB) allowing you to work off-line. For this reason, we recommend running this step ahead of the tutorial, with a reliable Internet connection. ## Using an IDE to work on the exercises During the exercises you will need to write code in multiple languages such as P4, Java, and Python. While the exercises do not prescribe the use of any specific IDE or code editor, the **ONF Cloud Tutorial Platform** provides access to a web-based version of Visual Studio Code (VS Code). If you are using the tutorial VM, you will find the Java IDE [IntelliJ IDEA Community Edition](https://www.jetbrains.com/idea/), already pre-loaded with plugins for P4 syntax highlighting and Python development. We suggest using IntelliJ IDEA especially when working on the ONOS app, as it provides code completion for all ONOS APIs. ## Repo structure This repo is structured as follows: * `p4src/` P4 implementation * `yang/` Yang model used in exercise 2 * `app/` custom ONOS app Java implementation * `mininet/` Mininet script to emulate a 2x2 leaf-spine fabric topology of `stratum_bmv2` devices * `util/` Utility scripts * `ptf/` P4 data plane unit tests based on Packet Test Framework (PTF) ## Tutorial commands To facilitate working on the exercises, we provide a set of make-based commands to control the different aspects of the tutorial. Commands will be introduced in the exercises, here's a quick reference: | Make command | Description | |---------------------|------------------------------------------------------- | | `make deps` | Pull and build all required dependencies | | `make p4-build` | Build P4 program | | `make p4-test` | Run PTF tests | | `make start` | Start Mininet and ONOS containers | | `make stop` | Stop all containers | | `make restart` | Restart containers clearing any previous state | | `make onos-cli` | Access the ONOS CLI (password: `rocks`, Ctrl-D to exit)| | `make onos-log` | Show the ONOS log | | `make mn-cli` | Access the Mininet CLI (Ctrl-D to exit) | | `make mn-log` | Show the Mininet log (i.e., the CLI output) | | `make app-build` | Build custom ONOS app | | `make app-reload` | Install and activate the ONOS app | | `make netcfg` | Push netcfg.json file (network config) to ONOS | ## Exercises Click on the exercise name to see the instructions: 1. [P4Runtime basics](./EXERCISE-1.md) 2. [Yang, OpenConfig, and gNMI basics](./EXERCISE-2.md) 3. [Using ONOS as the control plane](./EXERCISE-3.md) 4. [Enabling ONOS built-in services](./EXERCISE-4.md) 5. [Implementing IPv6 routing with ECMP](./EXERCISE-5.md) 6. [Implementing SRv6](./EXERCISE-6.md) 7. [Trellis Basics](./EXERCISE-7.md) 8. [GTP termination with fabric.p4](./EXERCISE-8.md) ## Solutions You can find solutions for each exercise in the [solution](solution) directory. Feel free to compare your solution to the reference one whenever you feel stuck. [![Build Status](https://travis-ci.org/opennetworkinglab/ngsdn-tutorial.svg?branch=advanced)](https://travis-ci.org/opennetworkinglab/ngsdn-tutorial)
1
hollowbit/libgdx-2d-tutorial
Github repo for my LibGDX 2D game development tutorials on YouTube.
null
# LibGDX 2D Tutorial Github repo for my LibGDX 2D game development tutorials on YouTube. You can find this tutorial series here: <a href="https://www.youtube.com/playlist?list=PLrnO5Pu2zAHKAIjRtTLAXtZKMSA6JWnmf">https://www.youtube.com/playlist?list=PLrnO5Pu2zAHKAIjRtTLAXtZKMSA6JWnmf</a>
0
HarryTechRevs/Minecraft-Modding-1.12
The repository for HarryTalks Minecraft Modding Tutorials on Minecraft Version 1.12 and 1.12.2
null
null
0
SomMeri/org.meri.jpa.tutorial
Examples and test cases for JPA tutorial.
null
null
0
mianasadali1/aExpress
Ecommerce Application Tutorial (Source) - Mian Speaks
null
# aExpress Ecommerce Application Tutorial (Source) - Mian Speaks # How to setup Admin Panel ###### Step 1: Download Source Code https://github.com/mianasadali1/aExpress/blob/master/Web%20Source%20Code/SourceCode.zip ###### Step 2: Upload Code & Database ###### Step 3: Change database credientals in services/conf.php file ###### All Done. # How to connect your panel with app ###### Step 1: In your android studio open Constants.java ###### Step 2: Change BASE_URL with your URL # Used Libraries Material Search Bar: https://github.com/mancj/MaterialSearchBar Rounded Image View: https://github.com/vinc3m1/RoundedImageView Carousel: https://github.com/ImaginativeShohag/Why-Not-Image-Carousel Android Volley: https://google.github.io/volley Tiny Cart: https://github.com/hishd/TinyCart Advanced Webview: https://github.com/delight-im/Android-AdvancedWebView # Free SVG Icons https://www.svgrepo.com
1
obviam/behavior-trees
Behavior Trees playground and tutorial
null
# behavior-trees This project accompanies the article: http://obviam.net/index.php/game-ai-an-introduction-to-behavior-trees ## How to use it Create a Java project in your favourite IDE and start playing with it. Have fun :-)
1
epickrram/perf-workshop
Tutorial on reducing Linux scheduler jitter
null
System Jitter Utility ===================== A test program for exploring causes of jitter. The application =============== ![Application diagram](doc/application.png) The application consists of 3 threads: 1. The producer thread - responsible for reading data from a memory-mapped file, inserting a timestamp, and publishing messages onto a queue (an instance of the [Disruptor] (https://github.com/LMAX-Exchange/disruptor)). 2. The accumulator (logic in the above diagram) thread - records a timestamp when it pulls a message from the queue, and stores the queue transit latency in a histogram. 3. The journaller thread - records a timestamp when it pulls a message from the queue, writes an entry to a journal containing the queue transit latency. All timestamps are generated by calling `System.nanoTime()`. The producer thread will busy-spin for ten microseconds between each publication. Consumer threads are busy-waiting on the head of the queue for messages to arrive from the producer. The application is garbage-free, and [guaranteed safepoints] (https://epickrram.blogspot.co.uk/2015/08/jvm-guaranteed-safepoints.html) are disabled, so there should be no jitter introduced by the JVM itself. Four latencies are recorded: 1. Queue transit time for accumulator thread 2. Queue transit time for journaller thread 3. Inter-message time for accumulator thread 4. Inter-message time for journaller thread On system exit, full histograms of these values are generated for post-processing (placed in `/tmp/` by default). Requirements ============ 1. JDK 8+ Tools to install ================ Install the following tools in order to work through the exercises: 1. gnuplot 2. perf 3. hwloc 4. trace-cmd 5. powertop Using ===== 1. Clone this git repository 2. Build the library: `./gradlew bundleJar` 3. Run it: `cd src/main/shell && bash ./run_test.sh BASELINE` Output ====== The `run_test.sh` script will run the application, using 'BASELINE' as a label. At exit, the application will print out a number of latency histograms. Below is an excerpt of the output containing the histogram of latencies recorded between the producer thread and the accumulator thread. == Accumulator Message Transit Latency (ns) == mean 60879 min 76 50.00% 168 90.00% 256 99.00% 2228239 99.90% 8126495 99.99% 10485823 99.999% 11534399 99.9999% 11534399 max 11534399 count 3595101 So for this run, 3.5m messages were passed through the queue, the mean latency was around 60 microseconds, min latency was 75 nanoseconds, and the max latency was over 11 milliseconds. These numbers can be plotted on a chart using the following command, executed from `src/main/shell`: `bash ./chart_accumulator_message_transit_latency.sh` and viewed with the following command: `gnuplot ./accumulator_message_transit_latency.cmd` producing something that looks like this chart: ![Baseline chart](doc/baseline-chart.png) Why so slow? ============ From these first results, we can see that at the 99th percentile, inter-thread latency was over 2 milliseconds, meaning that 1 in 100 messages took 2ms or longer to transit between two threads. Since no other work is being done by this program, the workload is constant, and there are no runtime pauses, where is this jitter coming from? Below are a series of steps working through some causes of system jitter on a modern Linux kernel (my laptop is running Fedora 22 on kernel 4.0.4). Most of these techniques have been tested on a 3.18 kernel, older versions may not have the same features/capabilities. CPU speed ========= Modern CPUs (especially on laptops) are designed to be power efficient, this means that the OS will typically try to scale down the clock rate when there is no activity. On Intel CPUs, this is partially handled using power-states, which allow the OS to reduce CPU frequency, meaning less power draw, and less thermal overhead. On current kernels, this is handled by the CPU scaling governor. You can check your current setting by looking in the file `/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor` on my laptop, this is set to `powersave` mode. To see available governors: `cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors` which tells me that I have two choices: 1. performance 2. powersave Before making a change though, let's make sure that powersave is actually causing us issues. To do this, we can use [perf_events] (https://perf.wiki.kernel.org/index.php/Main_Page) to monitor the CPU's P-state while the application is running: `perf record -e "power:cpu_frequency" -a` This command will sample the cpu_frequency trace point written to by the intel cpufreq driver on all CPUs. This information comes from an MSR on the chip which holds the FSB speed. Hit Ctrl+c once the application has finished running, then use `perf script` to view the available output. Filtering entries to include only those samples taken when `java` was executing shows some variation in the reported frequency: java 2804 [003] 3327.796741: power:cpu_frequency: state=1500000 cpu_id=3 java 2804 [003] 3328.089969: power:cpu_frequency: state=3000000 cpu_id=3 java 2804 [003] 3328.139009: power:cpu_frequency: state=2500000 cpu_id=3 java 2804 [003] 3328.204063: power:cpu_frequency: state=1000000 cpu_id=3 Set the scaling governor to performance mode to reduce this: `sudo bash ./set_cpu_governor.sh performance` and re-run the test while using `perf` to record `cpu_frequency` events. If the change has taken effect, there should be no events output by `perf script`. Running the test again with the performance governor enabled produces better results for inter-thread latency: == Accumulator Message Transit Latency (ns) == mean 23882 min 84 50.00% 152 90.00% 208 99.00% 589827 99.90% 4456479 99.99% 7340063 99.999% 7864351 99.9999% 8126495 max 8126495 count 3595101 Though there is still a max latency of 8ms, it has been reduced from the previous value of 11ms. The effect is clearly visible when added to the chart. To add the new data, go through the steps followed earlier: `bash ./chart_accumulator_message_transit_latency.sh` `gnuplot ./accumulator_message_transit_latency.cmd` ![Performance governor chart](doc/performance-chart.png) Process migration ================= Another possible cause of scheduling jitter is likely to be down to the OS scheduler moving processes around as different tasks become runnable. The important threads in the application are at the mercy of the scheduler, which can, at any time decide to run another process on the current CPU. When this happens, the running thread's context will be saved, and it will be shifted back into the schedulers run-queue (or possibly migrated to another CPU entirely). To find out whether this is happening to the threads in our application, we can turn to `perf` again and sample trace events emitted by the scheduler. First, record the PIDs of the two important threads from the application (producer and accumulator): Starting replay at Thu Sep 24 14:17:31 BST 2015 Accumulator thread has pid: 11372 Journaller thread has pid: 11371 Producer thread has pid: 11370 Warm-up complete at Thu Sep 24 14:17:35 BST 2015 Pausing for 10 seconds... Once warm-up has completed, record the scheduler events for the specific PIDs of interest: `perf record -e "sched:sched_stat_runtime" -t 11370 -t 11372` This command will record events emitted by the scheduler to update a task's runtime statistics. The recording session will exit once those processes complete. Running `perf script` again will show the captured events: `java 11372 [001] 3055.140623: sched:sched_stat_runtime: comm=java pid=11372 runtime=1000825 [ns] vruntime=81510486145 [ns]` The line above shows, among other things, what CPU the process was executing on when stats were updated. In this case, the process was running on CPU 001. A bit of sorting and counting will show exactly how the process was moved around the available CPUs during its lifetime: `perf script | grep "java 11372" | awk '{print $3}' | sort | uniq -c` 16071 [000] 10858 [001] 5778 [002] 7230 [003] So this thread mostly ran on CPUs 0 and 1, but also spent some time on CPUs 2 and 3. Moving the process around is going to require a context switch, and cache invalidation effects. While these are unlikely to be the sources of maximum latency, in order to start improving the worst-case, it will be necessary to stop migration of these processes. The application allows the user to select a target CPU for any of the three processing threads via a config file `/tmp/perf-workshop.properties`. Edit the file, and select two different CPUs for the producer and accumulator threads: perf.workshop.affinity.producer=1 perf.workshop.affinity.accumulator=3 Re-running the test shows a large improvement: ![Pinned threads chart](doc/pinned-thread-chart.png) This result implies that forcing the threads to run on a single CPU can help reduce inter-thread latency. Whether this is down to the scheduler making better decisions about where to run other processes, or simply because there is less context switching is not clear. One thing to look out for is the fact that we have not stopped the scheduler from running other tasks on those CPUs. We are still seeing multi-millisecond delays in message passing, and this could be down to other processes being run on the CPU that the application thread has been restricted to. Returning to `perf` and this time capturing all `sched_stat_runtime` events for a specific CPU (in this case 1) will show what other processes are being scheduled while the application is running: `perf record -e "sched:sched_stat_runtime" -C 1` Stripping out everything but the process name, and counting occurrences in the event trace shows that while the java application was running most of the time, there are plenty of other processes that were scheduled during the application's execution time: 45514 java 60 kworker/1:2 26 irq/39-DLL0665: 24 rngd 15 rcu_sched 9 gmain 8 goa-daemon 7 chrome 6 ksoftirqd/1 5 rtkit-daemon CPU Isolation ============= At this point, it's time to remove the target CPUs from the OS's scheduling domain. This can be done with the `isolcpus` boot parameter (i.e. add `isolcpus=1,3` to `grub.conf`), or by using the `cset` command from the `cpuset` package. In this case, I'm using `isolcpus` to stop the scheduler from running other userland processes on CPUs 1 & 3. The difference in inter-thread latency is dramatic: == Accumulator Message Transit Latency (ns) == mean 144 min 84 50.00% 144 90.00% 160 99.00% 208 99.90% 512 99.99% 2432 99.999% 3584 99.9999% 11776 max 14848 count 3595101 The difference is so great, that it's necessary to use a log-scale for the y-axis of the chart. ![Isolated CPUs](doc/isolcpus-chart-log-scale.png) Note that the difference will not be so great on a server-class machine with lots of spare processing power. The effect here is magnified by the fact that the OS only has 4 CPUs (on my laptop) to work with, and a desktop distribution of Linux. So there is much more scheduling pressure than would be present on a server-class machine. Using `perf` once again to confirm that other processes are not running on the reserved CPUs shows that there is still some contention to deal with: 81130 java 2 ksoftirqd/1 43 kworker/1:0 1 kworker/1:1H 2 kworker/3:1 1 kworker/3:1H 11 swapper These processes starting with 'k' are kernel threads that deal with house-keeping tasks on behalf of the OS, 'swapper' is the Linux idle process, which is scheduled whenever there is no work to be executed on a CPU.
1
amitrp/spring-examples
Contains Spring and Spring Boot Code Samples used in https://www.amitph.com/ tutorials
hibernate jpa-hibernate spring spring-boot spring-data-jdbc spring-data-jpa spring-data-rest spring-mvc
# Spring Tutorials and Examples Examples of using Spring Framework and Spring Boot These examples are part of Spring & Spring Boot Tutorials on https://www.amitph.com/ ## List of few relevant tutorials - [Spring Data REST CRUD Example](https://www.amitph.com/spring-data-rest-example/) - [Spring Data REST Projections and Excerpts](https://www.amitph.com/spring-data-rest-projections-and-excerpts/) - [Spring Data JDBC Tutorial with Examples](https://www.amitph.com/introduction-spring-data-jdbc/) - [Unit Tests for Spring Data JDBC Repositories](https://www.amitph.com/testing-spring-data-jdbc/) - [How to Write a non-web Application with Spring Boot](https://www.amitph.com/non-web-application-spring-boot/) - [CRUD REST Service With Spring Boot, Hibernate, and JPA](https://www.amitph.com/spring-boot-crud-hibernate-jpa/) - [Understand Http PUT vs PATCH with Examples](https://www.amitph.com/http-put-vs-patch/) - [Enable Spring Boot ApplicationStartup Metrics to Diagnose Slow Startup](https://www.amitph.com/spring-boot-startup-monitoring/) - [Scheduled Tasks in Spring with @Scheduled](https://www.amitph.com/scheduled-tasks-in-spring/) - [Spring Data JPA Composite Key with @EmbeddedId](https://www.amitph.com/spring-data-jpa-embeddedid/) - [Spring Data JPA find by @EmbeddedId Partially](https://www.amitph.com/spring-data-jpa-find-by-embeddedid-partially/) - [Spring Boot Actuator with Spring Boot 2](https://www.amitph.com/spring-boot-actuator-spring-boot-2/) - [Custom Health Check in Spring Boot Actuator](https://www.amitph.com/custom-health-check-spring-boot-actuator/) - [Introduction to Spring Boot Admin Server with Example](https://www.amitph.com/spring-boot-admin-server/) - [How to Secure Spring Boot Actuator Endpoints](https://www.amitph.com/how-to-secure-spring-boot-actuator-endpoints/) - [Spring Boot Admin Server Example](https://www.amitph.com/spring-boot-admin-server/) - [Spring Data and JPA Tutorial](https://www.amitph.com/spring-data-and-jpa-tutorial/) - [Wildcard Queries with Spring Data JPA](https://www.amitph.com/spring-data-and-jpa-tutorial/) - [Spring Boot Runners – Application Runner and Command Line Runner](https://www.amitph.com/spring-boot-runners/) - [Spring Boot Rest Service](https://www.amitph.com/spring-boot-rest-service/) - [Downloading Large Files using Spring WebClient](https://www.amitph.com/spring-webclient-large-file-download/) - [Spring @RequestParam Annotation with Examples](https://www.amitph.com/spring-requestparam-annotation/) - [Introduction to Spring WebClient](https://www.amitph.com/introduction-to-spring-webclient/) - [Configure timeout for Spring WebFlux WebClient](https://www.amitph.com/spring-webflux-timeouts/) - [How to Read JSON Data with WebClient](https://www.amitph.com/spring-webclient-read-json-data/) - [Add URI Parameters to Spring WebClient Requests](https://www.amitph.com/spring-webclient-request-parameters/) - [Spring Boot - Spring Data JPA - MySQL Example](https://www.amitph.com/spring-boot-data-jpa-mysql/) - [Spring Boot - Spring Data JPA - Postgres Example](https://www.amitph.com/spring-boot-data-jpa-postgres/) - [Spring Boot Exit Codes Examples with Exception Mapping](https://www.amitph.com/spring-boot-exit-codes/) - [Using @ConfigurationProperties in Spring Boot](https://www.amitph.com/spring-boot-configuration-properties/) - [Reading Nested Properties in Spring Boot](https://www.amitph.com/spring-boot-nested-configuration-properties/) - [Reading HTTP Headers in Spring REST Controller](https://www.amitph.com/spring-rest-http-header/) - [YAML to Map with Spring Boot](https://www.amitph.com/spring-boot-yaml-to-map/) - [YAML to Java List of Objects in Spring Boot](https://www.amitph.com/spring-boot-yaml-to-list/) - [Validations with @ConfigurationProperties in Spring Boot](https://www.amitph.com/spring-boot-configuration-properties-validation/) - [Parallel Requests with Spring WebClient](https://www.amitph.com/spring-webclient-concurrent-calls/) - [Custom Banners with Spring Boot](https://www.amitph.com/spring-boot-custom-banner/)
0
TheInvader360/libgdx-gameservices-tutorial
:video_game: Libgdx and google play game services tutorial
null
A sample application demonstrating how to integrate a LibGDX Android game with Google Play Game Services (leaderboards and achievements). The game itself is one of the example applications included with LibGDX (Super Jumper) [https://github.com/libgdx/libgdx/tree/master/demos/superjumper](https://github.com/libgdx/libgdx/tree/master/demos/superjumper) Open source and available on GitHub - [https://github.com/TheInvader360](https://github.com/TheInvader360) Companion tutorial on the blog - [http://theinvader360.blogspot.co.uk/2013/10/google-play-game-services-tutorial-example.html](http://theinvader360.blogspot.co.uk/2013/10/google-play-game-services-tutorial-example.html) Play a more complete version of the game (Super Jump a Doodle): [https://play.google.com/store/apps/details?id=com.theinvader360.jumping.superjumpadoodle.free](https://play.google.com/store/apps/details?id=com.theinvader360.jumping.superjumpadoodle.free)
1
lucmoreau/ProvToolbox
Java toolkit to create and convert W3C PROV data model representations, and build provenance-enabled applications in a variety of programming languages (java, python, typescript, javascript)
java json provenance provn provtoolbox rdf templates tutorials xml
Github.io --------- See ProvToolbox project page http://lucmoreau.github.io/ProvToolbox/ Javadoc ------- * PROV-MODEL Java implementation: https://javadoc.io/doc/org.openprovenance.prov/prov-model/latest/org/openprovenance/prov/model/package-summary.html * PROV-MODEL Scala implementation: https://javadoc.io/doc/org.openprovenance.prov/prov-model-scala/latest/org/openprovenance/prov/scala/immutable/index.html
0
afsalashyana/JavaFX-3D
JavaFX 3D Development Tutorial
javafx javafx-3d javafx-gui javafx-tutorial tutorial-code
## JavaFX 3D Tutorial Code Tutorial code collection for my course in [Genuine Coder YouTube Channel](https://www.youtube.com/playlist?list=PLhs1urmduZ295Ryetga7CNOqDymN_rhB_) #### [Tutorial Index](http://genuinecoder.com/javafx-3d) <img src="https://i.imgur.com/Esbb2mS.gif"> <img src="https://i.imgur.com/kUn591N.gif"> <img src="https://i.imgur.com/b0E87G6.gif"> <img src="https://i.imgur.com/uUWrzgN.gif"> <img src="https://i.imgur.com/LFnaCGZ.gif">
1
MonsterDeveloper/java-telegram-bot-tutorial
Java Telegram Bot Tutorial. Feel free to submit issue if you found a mistake.
book bot botapi bots chatbot chatbots guide java telegram telegram-bot telegram-bot-api telegrambot tutorial
--- search: keywords: - table of contents - getting started - readme --- * Note: this guide is not maintained. It's open for all contributions through GitHub. # Introduction [![Book Status](https://img.shields.io/badge/book-passing-brightgreen.svg)](https://www.gitbook.io/book/MonsterDeveloper/writing-telegram-bots-on-java/details) Hello everyone! While reading this book you will learn how to create Telegram Bots from start to finish. I assume you already know Java programming language. All sources are available at [GitHub repository](https://github.com/MonsterDeveloper/java-telegram-bot-tutorial/). ## Table of contents * [Lesson 1. Simple "echo" bot](chapter1.md) * [Lesson 2. PhotoBot](lesson-2.-photobot.md) * [Lesson 3. Logging](lesson-3.-logging.md) * [Lesson 4. Emoji](lesson-4.-emoji.md) * [Lesson 5. Deploy your bot](lesson-5.-deploy-your-bot.md) * [Lesson 6. Inline keyboards and editing message's text](lesson-6.-inline-keyboards-and-editing-messages-text.md) * [Lesson 7. Creating users database with MongoDB](lesson-7.-creating-users-database-with-mongodb.md) * [Lesson 8. Integrating with Redis](lesson-8-integrating-with-redis.md) ## Credits * [Rubenlagus](https://github.com/rubenlagus/) for his amazing library and support * [Clevero](https://github.com/Clevero) for his amazing HOWTO guide * [MasterGroosha](https://github.com/MasterGroosha) for his amazing Python book
0
BennyQBD/Wolfenstein3DClone
thebennybox Wolfenstein 3D clone from the tutorial
null
null
1
Naitsirc98/Vulkan-Tutorial-Java
Vulkan tutorial by Alexander Overvoorde ported to Java
assimp java lwjgl3 vulkan
# Vulkan-Tutorial-Java Java port of the [great tutorial by Alexander Overvoorde](https://vulkan-tutorial.com/). The original code can be found [here](https://github.com/Overv/VulkanTutorial). ![Tutorial Image 3](tutorial-image.jpg) --- * [Introduction](#introduction) * [LWJGL](#lwjgl) * [Native handles](#native-handles) * [Pointers and references](#pointers-and-references) * [Stack allocation](#stack-allocation) * [Drawing a triangle](#drawing-a-triangle) * [Setup](#setup) * [Base code](#base-code) * [Instance](#instance) * [Validation layers](#validation-layers) * [Physical devices and queue families](#physical-devices-and-queue-families) * [Logical device and queues](#logical-device-and-queues) * [Presentation](#presentation) * [Window surface](#window-surface) * [Swap chain](#swap-chain) * [Image views](#image-views) * [Graphics pipeline basics](#graphics-pipeline-basics) * [Introduction](#introduction-1) * [Shader Modules](#shader-modules) * [Fixed functions](#fixed-functions) * [Render passes](#render-passes) * [Conclusion](#conclusion) * [Drawing](#drawing) * [Framebuffers](#framebuffers) * [Command buffers](#command-buffers) * [Rendering and presentation](#rendering-and-presentation) * [Swapchain recreation](#swapchain-recreation) * [Vertex buffers](#vertex-buffers) * [Vertex input description](#vertex-input-description) * [Vertex buffer creation](#vertex-buffer-creation) * [Staging buffer](#staging-buffer) * [Version with dedicated Transfer Queue](#version-with-dedicated-transfer-queue) * [Index buffer](#index-buffer) * [Uniform buffers](#uniform-buffers) * [Descriptor layout and buffer](#descriptor-layout-and-buffer) * [Descriptor pool and sets](#descriptor-pool-and-sets) * [Texture mapping](#texture-mapping) * [Images](#images) * [Image view and sampler](#image-view-and-sampler) * [Combined image sampler](#combined-image-sampler) * [Depth buffering](#depth-buffering) * [Loading models](#loading-models) * [Generating Mipmaps](#generating-mipmaps) * [Multisampling](#multisampling) ## Introduction These tutorials are written to be easily followed with the C++ tutorial. However, I've made some changes to fit the Java and LWJGL styles. The repository follows the same structure as in the [original one](https://github.com/Overv/VulkanTutorial/tree/master/code). Every chapter have its own Java file to make them independent to each other. However, there are some common classes that many of them need: - [AlignmentUtils](src/main/java/javavulkantutorial/AlignmentUtils.java): Utility class for dealing with uniform buffer object alignments. - [Frame](src/main/java/javavulkantutorial/Frame.java): A wrapper around all the necessary Vulkan handles for an in-flight frame (*image-available semaphore*, *render-finished semaphore* and a *fence*). - [ModelLoader](src/main/java/javavulkantutorial/ModelLoader.java): An utility class for loading 3D models. They are loaded with [Assimp](http://www.assimp.org/). - [ShaderSPIRVUtils](src/main/java/javavulkantutorial/ShaderSPIRVUtils.java): An utility class for compiling GLSL shaders into SPIRV binaries at runtime. For maths calculations I will be using [JOML](https://github.com/JOML-CI/JOML), a Java math library for graphics mathematics. Its very similar to [GLM](https://glm.g-truc.net/0.9.9/index.html). Finally, each chapter have its own .diff file, so you can quickly see the changes made between chapters. Please note that the Java code is more verbose than C or C++, so the source files are larger. ## LWJGL I'm going to be using [LWJGL (Lightweight Java Game Library)](https://www.lwjgl.org/), a fantastic low level API for Java with bindings for GLFW, Vulkan, OpenGL, and other C libraries. If you don't know LWJGL, it may be difficult to you to understand certain concepts and patterns you will see throughout this tutorials. I will briefly explain some of the most important concepts you need to know to properly follow the code. ### Native handles Vulkan has its own handles named properly, such as VkImage, VkBuffer or VkCommandPool. These are unsigned integer numbers behind the scenes, and because Java does not have typedefs, we need to use *long* as the type of all of those objects. For that reason, you will see lots of *long* variables. ### Pointers and references Some structs and functions will take as parameters references and pointers to other variables, for example to output multiple values. Consider this function in C: ```C int width; int height; glfwGetWindowSize(window, &width, &height); // Now width and height contains the window dimension values ``` We pass in 2 *int* pointers, and the function writes the memory pointed by them. Easy and fast. But how about in Java? There is no concept of pointer at all. While we can pass a copy of a reference and modify the object's contents inside a function, we cannot do so with primitives. We have two options. We can use either an int array, which is effectively an object, or to use [Java NIO Buffers](https://docs.oracle.com/javase/7/docs/api/java/nio/Buffer.html). Buffers in LWJGL are basically a windowed array, with an internal position and limit. We are going to use these buffers, since we can allocate them off heap, as we will see later. Then, the above function will look like this with NIO Buffers: ```Java IntBuffer width = BufferUtils.createIntBuffer(1); IntBuffer height = BufferUtils.createIntBuffer(1); glfwGetWindowSize(window, width, height); // Print the values System.out.println("width = " + width.get(0)); System.out.println("height = " + height.get(0)); ``` Nice, now we can pass pointers to primitive values, but we are dynamically allocating 2 new objects for just 2 integers. And what if we only need these 2 variables for a short period of time? We need to wait for the Garbage Collector to get rid of those disposable variables. Luckily for us, LWJGL solves this problem with its own memory management system. You can learn about that [here](https://github.com/LWJGL/lwjgl3-wiki/wiki/1.3.-Memory-FAQ). ### Stack allocation In C and C++, we can easily allocate objects on the stack: ```C++ VkApplicationInfo appInfo = {}; // ... ``` However, this is not possible in Java. Fortunately for us, LWJGL allows us to kind of stack allocate variables on the stack. For that, we need a [MemoryStack](https://javadoc.lwjgl.org/org/lwjgl/system/MemoryStack.html) instance. Since a stack frame is pushed at the beginning of a function and is popped at the end, no matter what happens in the middle, we should use try-with-resources syntax to imitate this behaviour: ```Java try(MemoryStack stack = stackPush()) { // ... } // By this line, stack is popped and all the variables in this stack frame are released ``` Great, now we are able to use stack allocation in Java. Let's see how it looks like: ```Java try(MemoryStack stack = stackPush()) { IntBuffer width = stack.mallocInt(1); // 1 int unitialized IntBuffer height = stack.ints(0); // 1 int initialized with 0 glfwGetWindowSize(window, width, height); // Print the values System.out.println("width = " + width.get(0)); System.out.println("height = " + height.get(0)); } ``` Now let's see a real Vulkan example with *MemoryStack*: ```Java private void createInstance() { try(MemoryStack stack = stackPush()) { // Use calloc to initialize the structs with 0s. Otherwise, the program can crash due to random values VkApplicationInfo appInfo = VkApplicationInfo.calloc(stack); appInfo.sType(VK_STRUCTURE_TYPE_APPLICATION_INFO); appInfo.pApplicationName(stack.UTF8Safe("Hello Triangle")); appInfo.applicationVersion(VK_MAKE_VERSION(1, 0, 0)); appInfo.pEngineName(stack.UTF8Safe("No Engine")); appInfo.engineVersion(VK_MAKE_VERSION(1, 0, 0)); appInfo.apiVersion(VK_API_VERSION_1_0); VkInstanceCreateInfo createInfo = VkInstanceCreateInfo.calloc(stack); createInfo.sType(VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO); createInfo.pApplicationInfo(appInfo); // enabledExtensionCount is implicitly set when you call ppEnabledExtensionNames createInfo.ppEnabledExtensionNames(glfwGetRequiredInstanceExtensions()); // same with enabledLayerCount createInfo.ppEnabledLayerNames(null); // We need to retrieve the pointer of the created instance PointerBuffer instancePtr = stack.mallocPointer(1); if(vkCreateInstance(createInfo, null, instancePtr) != VK_SUCCESS) { throw new RuntimeException("Failed to create instance"); } instance = new VkInstance(instancePtr.get(0), createInfo); } } ``` ## Drawing a triangle ### Setup #### Base code [Read the tutorial](https://vulkan-tutorial.com/Drawing_a_triangle/Setup/Base_code) ![c++](cpp_icon.png)[Original code](https://github.com/Overv/VulkanTutorial/blob/master/code/00_base_code.cpp) ![java](java_icon.png)[Java code](src/main/java/javavulkantutorial/Ch00BaseCode.java) #### Instance [Read the tutorial](https://vulkan-tutorial.com/Drawing_a_triangle/Setup/Instance) ![c++](cpp_icon.png)[Original code](https://github.com/Overv/VulkanTutorial/blob/master/code/01_instance_creation.cpp) ![java](java_icon.png)[Java code](src/main/java/javavulkantutorial/Ch01InstanceCreation.java) ![diff](git_icon.png)[Diff](src/main/java/javavulkantutorial/Ch01InstanceCreation.diff) #### Validation layers [Read the tutorial](https://vulkan-tutorial.com/Drawing_a_triangle/Setup/Validation_layers) ![c++](cpp_icon.png)[Original code](https://github.com/Overv/VulkanTutorial/blob/master/code/02_validation_layers.cpp) ![java](java_icon.png)[Java code](src/main/java/javavulkantutorial/Ch02ValidationLayers.java) ![diff](git_icon.png)[Diff](src/main/java/javavulkantutorial/Ch02ValidationLayers.diff) #### Physical devices and queue families [Read the tutorial](https://vulkan-tutorial.com/Drawing_a_triangle/Setup/Physical_devices_and_queue_families) ![c++](cpp_icon.png)[Original code](https://github.com/Overv/VulkanTutorial/blob/master/code/03_physical_device_selection.cpp) ![java](java_icon.png)[Java code](src/main/java/javavulkantutorial/Ch03PhysicalDeviceSelection.java) ![diff](git_icon.png)[Diff](src/main/java/javavulkantutorial/Ch03PhysicalDeviceSelection.diff) #### Logical device and queues [Read the tutorial](https://vulkan-tutorial.com/Drawing_a_triangle/Setup/Logical_device_and_queues) ![c++](cpp_icon.png)[Original code](https://github.com/Overv/VulkanTutorial/blob/master/code/04_logical_device.cpp) ![java](java_icon.png)[Java code](src/main/java/javavulkantutorial/Ch04LogicalDevice.java) ![diff](git_icon.png)[Diff](src/main/java/javavulkantutorial/Ch04LogicalDevice.diff) ### Presentation #### Window surface [Read the tutorial](https://vulkan-tutorial.com/Drawing_a_triangle/Presentation/Window_surface) ![c++](cpp_icon.png)[Original code](https://github.com/Overv/VulkanTutorial/blob/master/code/05_window_surface.cpp) ![java](java_icon.png)[Java code](src/main/java/javavulkantutorial/Ch05WindowSurface.java) ![diff](git_icon.png)[Diff](src/main/java/javavulkantutorial/Ch05WindowSurface.diff) #### Swap chain [Read the tutorial](https://vulkan-tutorial.com/Drawing_a_triangle/Presentation/Swap_chain) ![c++](cpp_icon.png)[Original code](https://github.com/Overv/VulkanTutorial/blob/master/code/06_swap_chain_creation.cpp) ![java](java_icon.png)[Java code](src/main/java/javavulkantutorial/Ch06SwapChainCreation.java) ![diff](git_icon.png)[Diff](src/main/java/javavulkantutorial/Ch06SwapChainCreation.diff) #### Image views [Read the tutorial](https://vulkan-tutorial.com/Drawing_a_triangle/Presentation/Image_views) ![c++](cpp_icon.png)[Original code](https://github.com/Overv/VulkanTutorial/blob/master/code/07_image_views.cpp) ![java](java_icon.png)[Java code](src/main/java/javavulkantutorial/Ch07ImageViews.java) ![diff](git_icon.png)[Diff](src/main/java/javavulkantutorial/Ch07ImageViews.diff) ### Graphics pipeline basics #### Introduction [Read the tutorial](https://vulkan-tutorial.com/Drawing_a_triangle/Graphics_pipeline_basics) ![c++](cpp_icon.png)[Original code](https://github.com/Overv/VulkanTutorial/blob/master/code/08_graphics_pipeline.cpp) ![java](java_icon.png)[Java code](src/main/java/javavulkantutorial/Ch08GraphicsPipeline.java) ![diff](git_icon.png)[Diff](src/main/java/javavulkantutorial/Ch08GraphicsPipeline.diff) #### Shader Modules The shaders are compiled into SPIRV at runtime using [*shaderc*](https://github.com/google/shaderc) library. GLSL files are located at the [resources/shaders](src/main/resources/shaders/) folder. [Read the tutorial](https://vulkan-tutorial.com/Drawing_a_triangle/Graphics_pipeline_basics/Shader_modules) ![c++](cpp_icon.png)[Original code](https://github.com/Overv/VulkanTutorial/blob/master/code/09_shader_modules.cpp) ![java](java_icon.png)[Java code](src/main/java/javavulkantutorial/Ch09ShaderModules.java) ![diff](git_icon.png)[Diff](src/main/java/javavulkantutorial/Ch09ShaderModules.diff) #### Fixed functions [Read the tutorial](https://vulkan-tutorial.com/Drawing_a_triangle/Graphics_pipeline_basics/Fixed_functions) ![c++](cpp_icon.png)[Original code](https://github.com/Overv/VulkanTutorial/blob/master/code/10_fixed_functions.cpp) ![java](java_icon.png)[Java code](src/main/java/javavulkantutorial/Ch10FixedFunctions.java) ![diff](git_icon.png)[Diff](src/main/java/javavulkantutorial/Ch10FixedFunctions.diff) #### Render passes [Read the tutorial](https://vulkan-tutorial.com/Drawing_a_triangle/Graphics_pipeline_basics/Render_passes) ![c++](cpp_icon.png)[Original code](https://github.com/Overv/VulkanTutorial/blob/master/code/11_render_passes.cpp) ![java](java_icon.png)[Java code](src/main/java/javavulkantutorial/Ch11RenderPasses.java) ![diff](git_icon.png)[Diff](src/main/java/javavulkantutorial/Ch11RenderPasses.diff) #### Conclusion [Read the tutorial](https://vulkan-tutorial.com/Drawing_a_triangle/Graphics_pipeline_basics/Conclusion) ![c++](cpp_icon.png)[Original code](https://github.com/Overv/VulkanTutorial/blob/master/code/12_graphics_pipeline_complete.cpp) ![java](java_icon.png)[Java code](src/main/java/javavulkantutorial/Ch12GraphicsPipelineComplete.java) ![diff](git_icon.png)[Diff](src/main/java/javavulkantutorial/Ch12GraphicsPipelineComplete.diff) ### Drawing #### Framebuffers [Read the tutorial](https://vulkan-tutorial.com/Drawing_a_triangle/Drawing/Framebuffers) ![c++](cpp_icon.png)[Original code](https://github.com/Overv/VulkanTutorial/blob/master/code/13_framebuffers.cpp) ![java](java_icon.png)[Java code](src/main/java/javavulkantutorial/Ch13Framebuffers.java) ![diff](git_icon.png)[Diff](src/main/java/javavulkantutorial/Ch13Framebuffers.diff) #### Command buffers [Read the tutorial](https://vulkan-tutorial.com/Drawing_a_triangle/Drawing/Command_buffers) ![c++](cpp_icon.png)[Original code](https://github.com/Overv/VulkanTutorial/blob/master/code/14_command_buffers.cpp) ![java](java_icon.png)[Java code](src/main/java/javavulkantutorial/Ch14CommandBuffers.java) ![diff](git_icon.png)[Diff](src/main/java/javavulkantutorial/Ch14CommandBuffers.diff) #### Rendering and presentation [Read the tutorial](https://vulkan-tutorial.com/Drawing_a_triangle/Drawing/Rendering_and_presentation) ![c++](cpp_icon.png)[Original code](https://github.com/Overv/VulkanTutorial/blob/master/code/15_hello_triangle.cpp) ![java](java_icon.png)[Java code](src/main/java/javavulkantutorial/Ch15HelloTriangle.java) ![diff](git_icon.png)[Diff](src/main/java/javavulkantutorial/Ch15HelloTriangle.diff) ### Swapchain recreation [Read the tutorial](https://vulkan-tutorial.com/Drawing_a_triangle/Swap_chain_recreation) ![c++](cpp_icon.png)[Original code](https://github.com/Overv/VulkanTutorial/blob/master/code/16_swap_chain_recreation.cpp) ![java](java_icon.png)[Java code](src/main/java/javavulkantutorial/Ch16SwapChainRecreation.java) ![diff](git_icon.png)[Diff](src/main/java/javavulkantutorial/Ch16SwapChainRecreation.diff) ## Vertex buffers ### Vertex input description *(Will cause Validation Layer errors, but that will be fixed in the next chapter)* [Read the tutorial](https://vulkan-tutorial.com/Vertex_buffers/Vertex_input_description) ![c++](cpp_icon.png)[Original code](https://github.com/Overv/VulkanTutorial/blob/master/code/17_vertex_input.cpp) ![java](java_icon.png)[Java code](src/main/java/javavulkantutorial/Ch17VertexInput.java) ![diff](git_icon.png)[Diff](src/main/java/javavulkantutorial/Ch17VertexInput.diff) ### Vertex buffer creation [Read the tutorial](https://vulkan-tutorial.com/Vertex_buffers/Vertex_buffer_creation) ![c++](cpp_icon.png)[Original code](https://github.com/Overv/VulkanTutorial/blob/master/code/18_vertex_buffer.cpp) ![java](java_icon.png)[Java code](src/main/java/javavulkantutorial/Ch18VertexBuffer.java) ![diff](git_icon.png)[Diff](src/main/java/javavulkantutorial/Ch18VertexBuffer.diff) ### Staging buffer [Read the tutorial](https://vulkan-tutorial.com/Vertex_buffers/Staging_buffer) ![c++](cpp_icon.png)[Original code](https://github.com/Overv/VulkanTutorial/blob/master/code/19_staging_buffer.cpp) ![java](java_icon.png)[Java code](src/main/java/javavulkantutorial/Ch19StagingBuffer.java) ![diff](git_icon.png)[Diff](src/main/java/javavulkantutorial/Ch19StagingBuffer.diff) #### Version with dedicated Transfer Queue ![java](java_icon.png)[Java code](src/main/java/javavulkantutorial/Ch19StagingBufferTransferQueue.java) ![diff](git_icon.png)[Diff](src/main/java/javavulkantutorial/Ch19StagingBufferTransferQueue.diff) ### Index buffer [Read the tutorial](https://vulkan-tutorial.com/Vertex_buffers/Index_buffer) ![c++](cpp_icon.png)[Original code](https://github.com/Overv/VulkanTutorial/blob/master/code/20_index_buffer.cpp) ![java](java_icon.png)[Java code](src/main/java/javavulkantutorial/Ch20IndexBuffer.java) ![diff](git_icon.png)[Diff](src/main/java/javavulkantutorial/Ch20IndexBuffer.diff) ## Uniform buffers ### Uniform Buffer Object #### Descriptor layout and buffer [Read the tutorial](https://vulkan-tutorial.com/Uniform_buffers/Descriptor_layout_and_buffer) ![c++](cpp_icon.png)[Original code](https://github.com/Overv/VulkanTutorial/blob/master/code/21_descriptor_layout.cpp) ![java](java_icon.png)[Java code](src/main/java/javavulkantutorial/Ch21DescriptorLayout.java) ![diff](git_icon.png)[Diff](src/main/java/javavulkantutorial/Ch21DescriptorLayout.diff) #### Descriptor pool and sets [Read the tutorial](https://vulkan-tutorial.com/Uniform_buffers/Descriptor_pool_and_sets) ![c++](cpp_icon.png)[Original code](https://github.com/Overv/VulkanTutorial/blob/master/code/22_descriptor_sets.cpp) ![java](java_icon.png)[Java code](src/main/java/javavulkantutorial/Ch22DescriptorSets.java) ![diff](git_icon.png)[Diff](src/main/java/javavulkantutorial/Ch22DescriptorSets.diff) ## Texture mapping ### Images [Read the tutorial](https://vulkan-tutorial.com/Texture_mapping/Images) ![c++](cpp_icon.png)[Original code](https://github.com/Overv/VulkanTutorial/blob/master/code/23_texture_image.cpp) ![java](java_icon.png)[Java code](src/main/java/javavulkantutorial/Ch23TextureImage.java) ![diff](git_icon.png)[Diff](src/main/java/javavulkantutorial/Ch23TextureImage.diff) ### Image view and sampler [Read the tutorial](https://vulkan-tutorial.com/Texture_mapping/Image_view_and_sampler) ![c++](cpp_icon.png)[Original code](https://github.com/Overv/VulkanTutorial/blob/master/code/24_sampler.cpp) ![java](java_icon.png)[Java code](src/main/java/javavulkantutorial/Ch24Sampler.java) ![diff](git_icon.png)[Diff](src/main/java/javavulkantutorial/Ch24Sampler.diff) ### Combined image sampler [Read the tutorial](https://vulkan-tutorial.com/Texture_mapping/Combined_image_sampler) ![c++](cpp_icon.png)[Original code](https://github.com/Overv/VulkanTutorial/blob/master/code/25_texture_mapping.cpp) ![java](java_icon.png)[Java code](src/main/java/javavulkantutorial/Ch25TextureMapping.java) ![diff](git_icon.png)[Diff](src/main/java/javavulkantutorial/Ch25TextureMapping.diff) ## Depth buffering [Read the tutorial](https://vulkan-tutorial.com/Depth_buffering) ![c++](cpp_icon.png)[Original code](https://github.com/Overv/VulkanTutorial/blob/master/code/26_depth_buffering.cpp) ![java](java_icon.png)[Java code](src/main/java/javavulkantutorial/Ch26DepthBuffering.java) ![diff](git_icon.png)[Diff](src/main/java/javavulkantutorial/Ch26DepthBuffering.diff) ## Loading models The models will be loaded using [Assimp](), a library for loading 3D models in different formats which LWJGL has bindings for. I have wrapped all the model loading stuff into the [ModelLoader](src/main/java/javavulkantutorial/ModelLoader.java) class. [Read the tutorial](https://vulkan-tutorial.com/Loading_models) ![c++](cpp_icon.png)[Original code](https://github.com/Overv/VulkanTutorial/blob/master/code/27_model_loading.cpp) ![java](java_icon.png)[Java code](src/main/java/javavulkantutorial/Ch27ModelLoading.java) ![diff](git_icon.png)[Diff](src/main/java/javavulkantutorial/Ch27ModelLoading.diff) ## Generating Mipmaps [Read the tutorial](https://vulkan-tutorial.com/Generating_Mipmaps) ![c++](cpp_icon.png)[Original code](https://github.com/Overv/VulkanTutorial/blob/master/code/28_mipmapping.cpp) ![java](java_icon.png)[Java code](src/main/java/javavulkantutorial/Ch28Mipmapping.java) ![diff](git_icon.png)[Diff](src/main/java/javavulkantutorial/Ch28Mipmapping.diff) ## Multisampling [Read the tutorial](https://vulkan-tutorial.com/Multisampling) ![c++](cpp_icon.png)[Original code](https://github.com/Overv/VulkanTutorial/blob/master/code/29_multisampling.cpp) ![java](java_icon.png)[Java code](src/main/java/javavulkantutorial/Ch29Multisampling.java) ![diff](git_icon.png)[Diff](src/main/java/javavulkantutorial/Ch29Multisampling.diff) --- *Icons made by [Icon Mafia](https://iconscout.com/contributors/icon-mafia)*
1
mraible/jhipster5-demo
Get Started with JHipster 5 Tutorial and Example
angular java jhipster jwt-authentication spring-boot typescript webpack
# blog This application was generated using JHipster 5.0.1, you can find documentation and help at [https://www.jhipster.tech/documentation-archive/v5.0.1](https://www.jhipster.tech/documentation-archive/v5.0.1). ## Development Before you can build this project, you must install and configure the following dependencies on your machine: 1. [Node.js][]: We use Node to run a development web server and build the project. Depending on your system, you can install Node either from source or as a pre-packaged bundle. 2. [Yarn][]: We use Yarn to manage Node dependencies. Depending on your system, you can install Yarn either from source or as a pre-packaged bundle. After installing Node, you should be able to run the following command to install development tools. You will only need to run this command when dependencies change in [package.json](package.json). yarn install We use yarn scripts and [Webpack][] as our build system. Run the following commands in two separate terminals to create a blissful development experience where your browser auto-refreshes when files change on your hard drive. ./mvnw yarn start [Yarn][] is also used to manage CSS and JavaScript dependencies used in this application. You can upgrade dependencies by specifying a newer version in [package.json](package.json). You can also run `yarn update` and `yarn install` to manage dependencies. Add the `help` flag on any command to see how you can use it. For example, `yarn help update`. The `yarn run` command will list all of the scripts available to run for this project. ### Service workers Service workers are commented by default, to enable them please uncomment the following code. * The service worker registering script in index.html ```html <script> if ('serviceWorker' in navigator) { navigator.serviceWorker .register('./service-worker.js') .then(function() { console.log('Service Worker Registered'); }); } </script> ``` Note: workbox creates the respective service worker and dynamically generate the `service-worker.js` ### Managing dependencies For example, to add [Leaflet][] library as a runtime dependency of your application, you would run following command: yarn add --exact leaflet To benefit from TypeScript type definitions from [DefinitelyTyped][] repository in development, you would run following command: yarn add --dev --exact @types/leaflet Then you would import the JS and CSS files specified in library's installation instructions so that [Webpack][] knows about them: Edit [src/main/webapp/app/vendor.ts](src/main/webapp/app/vendor.ts) file: ~~~ import 'leaflet/dist/leaflet.js'; ~~~ Edit [src/main/webapp/content/css/vendor.css](src/main/webapp/content/css/vendor.css) file: ~~~ @import '~leaflet/dist/leaflet.css'; ~~~ Note: there are still few other things remaining to do for Leaflet that we won't detail here. For further instructions on how to develop with JHipster, have a look at [Using JHipster in development][]. ### Using angular-cli You can also use [Angular CLI][] to generate some custom client code. For example, the following command: ng generate component my-component will generate few files: create src/main/webapp/app/my-component/my-component.component.html create src/main/webapp/app/my-component/my-component.component.ts update src/main/webapp/app/app.module.ts ## Building for production To optimize the blog application for production, run: ./mvnw -Pprod clean package This will concatenate and minify the client CSS and JavaScript files. It will also modify `index.html` so it references these new files. To ensure everything worked, run: java -jar target/*.war Then navigate to [http://localhost:8080](http://localhost:8080) in your browser. Refer to [Using JHipster in production][] for more details. ## Testing To launch your application's tests, run: ./mvnw clean test ### Client tests Unit tests are run by [Jest][] and written with [Jasmine][]. They're located in [src/test/javascript/](src/test/javascript/) and can be run with: yarn test UI end-to-end tests are powered by [Protractor][], which is built on top of WebDriverJS. They're located in [src/test/javascript/e2e](src/test/javascript/e2e) and can be run by starting Spring Boot in one terminal (`./mvnw spring-boot:run`) and running the tests (`yarn run e2e`) in a second one. ### Other tests Performance tests are run by [Gatling][] and written in Scala. They're located in [src/test/gatling](src/test/gatling). To use those tests, you must install Gatling from [https://gatling.io/](https://gatling.io/). For more information, refer to the [Running tests page][]. ## Using Docker to simplify development (optional) You can use Docker to improve your JHipster development experience. A number of docker-compose configuration are available in the [src/main/docker](src/main/docker) folder to launch required third party services. For example, to start a postgresql database in a docker container, run: docker-compose -f src/main/docker/postgresql.yml up -d To stop it and remove the container, run: docker-compose -f src/main/docker/postgresql.yml down You can also fully dockerize your application and all the services that it depends on. To achieve this, first build a docker image of your app by running: ./mvnw verify -Pprod dockerfile:build dockerfile:tag@version dockerfile:tag@commit Then run: docker-compose -f src/main/docker/app.yml up -d For more information refer to [Using Docker and Docker-Compose][], this page also contains information on the docker-compose sub-generator (`jhipster docker-compose`), which is able to generate docker configurations for one or several JHipster applications. ## Continuous Integration (optional) To configure CI for your project, run the ci-cd sub-generator (`jhipster ci-cd`), this will let you generate configuration files for a number of Continuous Integration systems. Consult the [Setting up Continuous Integration][] page for more information. [JHipster Homepage and latest documentation]: https://www.jhipster.tech [JHipster 5.0.1 archive]: https://www.jhipster.tech/documentation-archive/v5.0.1 [Using JHipster in development]: https://www.jhipster.tech/documentation-archive/v5.0.1/development/ [Using Docker and Docker-Compose]: https://www.jhipster.tech/documentation-archive/v5.0.1/docker-compose [Using JHipster in production]: https://www.jhipster.tech/documentation-archive/v5.0.1/production/ [Running tests page]: https://www.jhipster.tech/documentation-archive/v5.0.1/running-tests/ [Setting up Continuous Integration]: https://www.jhipster.tech/documentation-archive/v5.0.1/setting-up-ci/ [Gatling]: http://gatling.io/ [Node.js]: https://nodejs.org/ [Yarn]: https://yarnpkg.org/ [Webpack]: https://webpack.github.io/ [Angular CLI]: https://cli.angular.io/ [BrowserSync]: http://www.browsersync.io/ [Jest]: https://facebook.github.io/jest/ [Jasmine]: http://jasmine.github.io/2.0/introduction.html [Protractor]: https://angular.github.io/protractor/ [Leaflet]: http://leafletjs.com/ [DefinitelyTyped]: http://definitelytyped.org/
1
redhat-developer-demos/kafka-tutorial
Kafka Tutorial for https://dn.dev/kafkamaster
null
null
1
coolAlias/Tutorial-Demo
Demo of various topics covered in my forge tutorials
null
Tutorial Demo =============== Demo of various topics covered in my forge tutorials, namely IExtendedEntityProperties / Capabilities and custom inventories, with updated network code, a working mana bar, an item that uses mana, and a custom player inventory that can only hold the mana item. I may add more later. Older versions of the demo are on different branches, e.g. 1.7.10 for that version.
0
CodeNMore/New-Beginner-Java-Game-Programming-Src
The New Beginner Java Game Programming Tutorial Series" - contains every episode's individual source code!"
null
# The New Beginner Java Game Programming Series ## Read Me First This project was started in 2014, and slowly continued into 2016. The code found here was part of a tutorial series found [here](https://www.youtube.com/playlist?list=PLah6faXAgguMnTBs3JnEJY0shAc18XYQZ) on the CodeNMore channel. Remember that the code here is not the only way to do something, and the final video of the series discusses some of the good and bad design decisions made while creating this project, how it can be improved, and how developers are constantly learning. An updated series can be found on the CodeNMore channel utilizing the LibGDX game engine as of mid-2020. ## Source Code The source code for each episode in the series can be found here. Look in this repository and select the folder that corresponds to the episode number you are looking for. Within that folder is my own Eclipse project folder, though you don't need Eclipse to view any of the source code or run it.
1
caveofprogramming/java-beginners-11
Code for Java 11 for Complete Beginners tutorial
null
# java-beginners-11 Code for Java 11 for Complete Beginners tutorial https://www.udemy.com/course/java-11-complete-beginners
1
jonashackt/tutorial-soap-spring-boot-cxf
Tutorial how to create, test, deploy, monitor SOAP-Webservices using Spring Boot and Apache CXF
apache-cxf cxf integration-testing jax-ws spring-boot spring-boot-starter wsdl
# tutorial-soap-spring-boot-cxf Tutorial how to create, test, deploy, monitor SOAP-Webservices using [Spring Boot](http://projects.spring.io/spring-boot/), [Apache CXF](https://cxf.apache.org/) and [JAX-WS](https://de.wikipedia.org/wiki/Java_API_for_XML_Web_Services) Every following step builds upon the preceding one. So if you start e.g. with step 3, you´ll have all of step 1 & 2 covered in the code. ### The Steps 1-3: published accompanying the blog-posts: [Spring Boot & Apache CXF – How to SOAP in 2016](https://blog.codecentric.de/en/2016/02/spring-boot-apache-cxf/) (or german version: [Spring Boot & Apache CXF – SOAP ohne XML?](https://blog.codecentric.de/2016/02/spring-boot-apache-cxf/) ) [step1_simple_springboot_app_with_cxf](https://github.com/jonashackt/tutorial-soap-spring-boot-cxf/tree/master/step1_simple_springboot_app_with_cxf) Shows you, how to set up a simple Spring Boot Application and bootstrap a runnable CXF-Framework within the embedded Tomcat. [step2_wsdl_2_java_maven](https://github.com/jonashackt/tutorial-soap-spring-boot-cxf/tree/master/step2_wsdl_2_java_maven) Inherits a completely altered example WebService-Definition as WSDL inspired from the popular http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL Shows, how to generate JAXB-Classes from WSDL with JAX-WS Commons Maven plugin at build time - just run ``` mvn clean generate-sources ``` [step3_jaxws-endpoint-cxf-spring-boot](https://github.com/jonashackt/tutorial-soap-spring-boot-cxf/tree/master/step3_jaxws-endpoint-cxf-spring-boot) First running SOAP-Endpoint with SpringBoot, CXF and JAX-WS. For testing use [SoapUI](https://www.soapui.org/) (Testing our Service inside a Unittest will be part of a further Step). [step3_jaxws-endpoint-cxf-spring-boot-orig-wsdl](https://github.com/jonashackt/tutorial-soap-spring-boot-cxf/tree/master/step3_jaxws-endpoint-cxf-spring-boot-orig-wsdl) Full-Contract-First with using the generated JAX-WS Service-Class to not wrap WSDL and use original one - includes correct URL and TargetNamespace (recommended) ### The Steps 4: published accompanying the blog-posts: [Spring Boot & Apache CXF – Testing SOAP Web Services](https://blog.codecentric.de/en/2016/06/spring-boot-apache-cxf-testing-soap-webservices/) (or german version: [Spring Boot & Apache CXF – SOAP-Webservices testen](https://blog.codecentric.de/2016/06/spring-boot-apache-cxf-soap-webservices-testen/) ) [step4_test](https://github.com/jonashackt/tutorial-soap-spring-boot-cxf/tree/master/step4_test) Unit-, Integration- and Single-System-Integration-Tests with Spring (Boot) and Apache CXF ### The Steps 5: published accompanying the blog-posts: [Spring Boot & Apache CXF – XML validation and custom SOAP faults](https://blog.codecentric.de/en/2016/06/spring-boot-apache-cxf-xml-validation-custom-soap-faults/) (or german version: [Spring Boot & Apache CXF – XML-Validierung und Custom SOAP Faults](https://blog.codecentric.de/2016/06/spring-boot-apache-cxf-xml-validierung-custom-soap-faults/) ) [step5_custom-soap-fault](https://github.com/jonashackt/tutorial-soap-spring-boot-cxf/tree/master/step5_custom-soap-fault) Custom SOAP faults after XML schema validation, that are valid against an XSD itself and will be fired, regardles what will enter your endpoint :) ### The Steps 6-9: published accompanying the blog-posts: [Spring Boot & Apache CXF – Logging & Monitoring with Logback, Elasticsearch, Logstash & Kibana](https://blog.codecentric.de/en/2016/07/spring-boot-apache-cxf-logging-monitoring-logback-elasticsearch-logstash-kibana/) (or german version: [Spring Boot & Apache CXF – Logging & Monitoring mit Logback, Elasticsearch, Logstash & Kibana](https://blog.codecentric.de/2016/07/spring-boot-apache-cxf-logging-monitoring-logback-elasticsearch-logstash-kibana/) ) [step6_soap_message_logging](https://github.com/jonashackt/tutorial-soap-spring-boot-cxf/tree/master/step6_soap_message_logging) How to configure SOAP message logging on Apache CXF endpoints [step7_soap_message_logging_payload_only](https://github.com/jonashackt/tutorial-soap-spring-boot-cxf/tree/master/step7_soap_message_logging_payload_only) Tailor Apache CXF´s SOAP message log statements< [step8_logging_into_elasticstack](https://github.com/jonashackt/tutorial-soap-spring-boot-cxf/tree/master/step8_logging_into_elasticstack) Elasticsearch, Logstash, Kibana - How to log SOAP messages in 2016, including: * Configuring the logstash-logback-encoder [step9_soap_message_logging_into_custom_elasticsearch_field](https://github.com/jonashackt/tutorial-soap-spring-boot-cxf/tree/master/step9_soap_message_logging_into_custom_elasticsearch_field) * Logging SOAP messages into their own Elasticsearch fields * Correlating all Log-Events concerning a specific SOAP request ### The Steps 10: published accompanying the blog-posts: [Spring Boot & Apache CXF – SOAP on steroids fueled by cxf-spring-boot-starter](https://blog.codecentric.de/en/2016/10/spring-boot-apache-cxf-spring-boot-starter/) (or german version: [Spring Boot & Apache CXF – Von 0 auf SOAP mit dem cxf-spring-boot-starter](https://blog.codecentric.de/2016/10/spring-boot-apache-cxf-spring-boot-starter/) ) [step10_simple_app_with_cxf-spring-boot-starter](https://github.com/jonashackt/tutorial-soap-spring-boot-cxf/tree/master/step10_simple_app_with_cxf-spring-boot-starter) * Showing, how to quickly use every possible solution of all previous steps with the [cxf-spring-boot-starter](https://github.com/codecentric/cxf-spring-boot-starter)
1
Nosfert/AspectJ-Tutorial-jayway
AspectJ-Tutorial blog.jayway.com
null
# AspectJ-Tutorial-jayway AspectJ-Tutorial blog.jayway.com ### Initially do Go to [parent-folder] and run mvn clean install #### Run application Go to the [application-folder]/target and run java -jar [application-file].jar
0
REME-easy/SlayTheSpireModTutorials
A series of tutorials of how to make a mod for the game Slay The Spire.
slaythespire slaythespire-mod
杀戮尖塔mod制作教程 ===================== <b>本教程不会讲解Java编程知识,建议先了解一些编程基础再来学习。</b> <b>点击上方的Tutorials文件夹或者右侧的[教程网站](https://reme-easy.github.io/SlayTheSpireModTutorials/)查看所有教程。</b> 杀戮尖塔mod交流群:723677239 # 一些实用的工具/网站 ## 目录 * [网站](#网站) * [工具](#工具) * [mod样板](mod样板) * [动画](#动画) * [和尖塔无关但你也许需要](#和尖塔无关但你也许需要) ## 网站 * [ModTheSpire Wiki](https://github.com/kiooeht/ModTheSpire/wiki)<br> <b>ModTheSpire</b>(简称MTS)是一种无需修改基础游戏文件即可为 Slay the Spire 加载外部模组的工具,同时允许模组将自己的代码修补到游戏代码中。<br> MTS Wiki上写了如何进行全局保存、patch等。 * [BaseMod Wiki](https://github.com/daviscook477/BaseMod/wiki)<br> <b>BaseMod</b>是模组的基础API,能够让mod作者方便的向游戏中添加自己的卡牌等内容并且集中管理这些内容。<br> Wiki上写了一些很实用的小工具,例如自动注册所有卡牌(AutoAdd)、卡牌修改器(CardModifier)、一局游戏内保存(CustomSavable)等。也包括BaseMod作者写的mod制作教程。 ## 工具 * [JD-GUI](http://java-decompiler.github.io/)<br> 一个Java反编译工具,具有GUI界面。<br> 可以让你查看游戏或其他mod重构后的源代码方便~~拷贝~~学习其他人的代码。<br> 也可以用来查询打patch需要的行数。(idea自带的反编译不准确) * [sts裁图器](https://github.com/JohnnyBazooka89/StSModdingToolCardImagesCreator)<br> 把图片裁剪成尖塔卡图需要的形状和尺寸。<br> 我并没有用过这个,群里有群友自己制作的另一个相同功能的工具。 ## mod样板 * [战神徽章mod](https://github.com/Rita-Bernstein/Warlord-Emblem)<br> ~~Rita推荐,必属精品~~<br> 比较标准化的一个mod范例。 ## 动画 *制作动画需要一些基础,但其实大多数mod只需要一张图就够了。* * [Spine](http://zh.esotericsoftware.com/)<br> 尖塔使用的2D动画软件,要钱的,不推荐。 * [龙骨](https://dragonbones.github.io/cn/index.html)<br> 可以导出spine动画的软件,目前网站无法下载可用版本(只能使用最新版),可以来自己找或者来群里要。 ## 和尖塔无关但你也许需要 * [SourceGraph](https://sourcegraph.com/search)<br> 一个可以快速浏览Github储存库的网站(有Chrome扩展程序,可以在Github页面点击进入相应网页),用起来比Github浏览速度快,并且代码结构清晰,可以在Github抽风时使用。 * [Github文件加速](https://gh.api.99988866.xyz/)<br> 一个可以快速下载Github Release的网站。
0
SilentChaos512/Tutorial-Mod
Tutorial mods for Minecraft
null
# Tutorial Minecraft Mod Video tutorials on [YouTube](https://www.youtube.com/silentchaos512)
1
mahmoudhamwi/Fruits-Market
Watch Fruits Market Tutorial on youtube:
null
# Fruits-Market # Tutorial Watch Fruits Market Tutorial step by step on youtube: https://youtu.be/0IDuEPCo1oY # Screenshot ![alt text](https://raw.githubusercontent.com/mahmoudhamwi/Fruits-Market/master/FruitMarket/Screenshot/image1.png) ![alt text](https://raw.githubusercontent.com/mahmoudhamwi/Fruits-Market/master/FruitMarket/Screenshot/image2.PNG) ![alt text](https://raw.githubusercontent.com/mahmoudhamwi/Fruits-Market/master/FruitMarket/Screenshot/image3.PNG) ![alt text](https://raw.githubusercontent.com/mahmoudhamwi/Fruits-Market/master/FruitMarket/Screenshot/image4.PNG)
1
BracketCove/RecyclerViewTutorial2017
2017 RecyclerView Tutorial by Ryan Kay (wiseAss).
null
## RecyclerViewTutorial2017 2017 RecyclerView Tutorial by Ryan Kay (wiseAss). **Part 1: Project OverView, is available to watch here:** https://www.youtube.com/watch?v=RfTJ2SePYaU&feature=youtu.be **Part 2: Basic RecyclerView** https://www.youtube.com/watch?v=mw1wkYEJ1vI Preview: <img src="Screenshot_20170708-095736_framed.png" alt="Part Two Preview" width="270" height="480"/> **Part 3: Advanced RecyclerView Design and Features** https://www.youtube.com/watch?v=-xuhicDXMvw **Preview:** <img src="Screenshot_20170713-081532_framed.png" alt="Part Three Preview" width="270" height="480"/> Welcome to my Android RecyclerView Tutorial. About a year ago, I got so pissed off at how overly complicated it was to get a decent RecyclerView running (which is also my fault for not being a better learner), that I decided to make series on Youtube about it. Much to my surprise, my long winded explanations and random tangents was something that a few people actually enjoyed. While I didn't make any MAJOR mistakes with the old tutorial, I was still pretty much a Junior Developer on the Android Platform at that point. Since then, I've learned a great deal about making Android Apps, and even more about teaching people how to make them; so here you have it. Please bare in mind that while I'm getting ok at this Android thing, there's always room to learn. If there's anything in my Code which strikes you as being wrong or sub-optimal, please open a GitHub Issue and let me know about it! Bonus points if you take the time to actually explain why I'm wrong; I don't have a lot of spare time and I appreciate good feedback when I can get it. ## For Beginners The Videos are made for you. I'll do my best to give you the following: - A fundamental understanding of how RecyclerViews and RecyclerView.Adapters work - A working App which implements the above - Good Software Architecture Principles whenever I feel like I can work them in to what I'm talking about - A brief explanation of Unit Tests (let's not worry about what they ARE, I'll actually show you what they can DO for us) - General Best Practices for Android App building (well, as far as I'm aware) - Some of the Layouts use ConstraintLayout - A West Coast Canadian accent. ## For Not Beginners Read my code. I try to give everything good descriptive names, and I built my Software to basics standards of Software Architecture and SOLID Principles whenever possible. ## For All If nothing else, I hope this project demonstrates that while it's great to learn stuff from Videos and Textbooks, looking at/creating well documented Code with good naming Conventions, is something you should work towards. Whether you are looking at your own old Code, or working with other people, do us all a favour and don't just bang out a bunch of ugly crap with bad names and a Package Structure that doesn't make any sense. The names and Package Structure should help people understand your code, not piss them off. </rant> ## About Me I'm an Indie Android Dev living in Victoria BC Canada. I'm a major Nerd, and rambling about Software is quite therapeutic for me, to the extent that I have a [Youtube Channel](https://www.youtube.com/user/gosuddr93) mostly dedicated to that. I also do a Weekly Live Android Developer Q&A Series most Sundays at 9:00AM PDT (GMT -7). You can watch that at the aforementioned time [here](https://www.youtube.com/c/wiseAss/live). **Please Read** I don't release this stuff for free because I don't like money. Actually, I could use all the help I can get to improve my Equipment, Production Quality, Content, and pay my living expenses. If my content is worth even the average fancy Hipster Coffee to you, then please Consider sending me a Fiver once on Patreon. ## Social Media Facebook: https://www.facebook.com/wiseassblog/ G+: https://plus.google.com/+wiseass Twitter: https://twitter.com/wiseass301 Patreon: https://www.patreon.com/bePatron?u=5114325 Blog: http://wiseassblog.com/
1
eiselems/spring-boot-microservices
This repo is part of a tutorial about writing microservices using Spring Boot
microservice microservices-architecture netflix-oss spring-boot spring-boot-microservice tutorial
# spring-boot-microservices This repository contains the coding part of 'Microservices with Mo'. A tutorial series about creating an microservice architecture with Spring Boot. Here are the links to all parts of the series: * [Intro](https://medium.com/@marcus.eisele/implementing-a-microservice-architecture-with-spring-boot-intro-cdb6ad16806c "Implementing a microservice architecture with Spring Boot — Intro") * [Part 1: Setting up docker](https://medium.com/@marcus.eisele/implementing-a-microservice-architecture-with-spring-boot-part-one-the-environment-cbc032473ab8 "Setting up docker") * [Part 2: The architecture](https://medium.com/@marcus.eisele/microservices-with-mo-part-two-the-architecture-3845b5228ddb "Microservices with Mo - Part Two: The architecture") * [Part 3: The counter microservice](https://medium.com/@marcus.eisele/microservices-with-mo-part-three-the-counter-microservice-5fa34af2dcdc "Microservices with Mo — Part Three: The Counter Microservice") * [Part 4: The configuration microservice](https://medium.com/@marcus.eisele/microservices-with-mo-part-four-the-configuration-service-7d9a5b1b4f72 "Microservices with Mo — Part Four: The Configuration Service") * [Part 5: The registry microservice](https://medium.com/@marcus.eisele/microservices-with-mo-part-five-the-registry-service-netflix-eureka-96f0de083252 "Microservices with Mo — Part Five: The Registry Service (Netflix Eureka)") * [Part 6: The gateway microservice](https://medium.com/@marcus.eisele/spring-boot-microservices-part-six-the-gateway-service-netflix-zuul-55f8d97b731d "Microservices with Mo — Part Six: The Gateway Service (Netflix Zuul)") The architecture consists / will consist of following services: * counterservice * configservice * servicediscovery * adminservice * gatewayservice ## How to run ``` git clone https://github.com/eiselems/spring-boot-microservices.git && cd spring-boot-microservices mvn clean package -DskipTests && docker-compose up --build ``` Access http://localhost:9999/api/cs/count and refresh a few times to see the counter increase. You also can access the counterservice itself directly at http://localhost:8080/count.
1
in28minutes/master-spring-and-spring-boot
Spring and Spring Boot Tutorial For Absolute Beginners - 10-in-1 - Spring to Spring Boot to REST API to Full Stack to Containers to Cloud
aws docker java spring spring-boot spring-security
# Master Spring and Spring Boot **Spring and Spring Boot** Frameworks are the **No 1 frameworks** for building enterprise apps in the Java world. In this course, you will **learn Spring and Spring Boot from ZERO**. I'm a great believer that the best way to learn is by doing and we designed this course to be **hands-on**. You will build a **web application, a REST API and full stack application** using Spring, Spring Boot, JPA, Hibernate, React, Spring Security, Maven and Gradle. You will learn to containerise applications using Docker. You will learn to deploy these applications to AWS. By the end of the course, you will know everything you would need to become a great Spring and Spring Boot Developer. ## Installing Tools ### Our Recommendations - Use **latest version** of Java - Use **latest version** of "Eclipse IDE for Enterprise Java Developers" - Remember: Spring Boot 3+ works only with Java 17+ ### Installing Java - Windows - https://www.youtube.com/watch?v=I0SBRWVS0ok - Linux - https://www.youtube.com/watch?v=mHvFpyHK97A - Mac - https://www.youtube.com/watch?v=U3kTdMPlgsY #### Troubleshooting - Troubleshooting Java Installation - https://www.youtube.com/watch?v=UI_PabQ1YB0 ### Installing Eclipse - Windows - https://www.youtube.com/watch?v=toY06tsME-M - Others - https://www.youtube.com/watch?v=XveQ9Gq41UM #### Troubleshooting - Configuring Java in Eclipse - https://www.youtube.com/watch?v=8i0r_fcE3L0 ## Lectures ### Getting Started - Master Spring Framework and Spring Boot - Getting Started - Master Spring Framework and Spring Boot ### Getting Started with Java Spring Framework - Step 01 - Understanding the Need for Java Spring Framework - Step 02 - Getting Started with Java Spring Framework - Step 03 - Creating a New Spring Framework Project with Maven and Java - Step 04 - Getting Started with Java Gaming Application - Step 05 - Understanding Loose Coupling and Tight Coupling - Step 06 - Introducting Java Interface to Make App Loosely Coupled - Step 07 - Bringing in Spring Framework to Make Java App Loosely Coupled - Step 08 - Your First Java Spring Bean and Launching Java Spring Configuration - Step 09 - Creating More Java Spring Beans in Spring Java Configuration File - Step 10 - Implementing Auto Wiring in Spring Framework Java Configuration File - Step 11 - Questions about Spring Framework - What will we learn? - Step 12 - Understanding Spring IOC Container - Application Context and Bean Factory - Step 13 - Exploring Java Bean vs POJO vs Spring Bean - Step 14 - Exploring Spring Framework Bean Auto Wiring - Primary and Qualifier Annotations - Step 15 - Using Spring Framework to Manage Beans for Java Gaming App - Step 16 - More Questions about Java Spring Framework - What will we learn? - Step 17 - Exploring Spring Framework With Java - Section 1 - Review ### Using Spring Framework to Create and Manage Your Java Objects - Step 01 - Getting Spring Framework to Create and Manage Your Java Objects - Step 02 - Exploring Primary and Qualifier Annotations for Spring Components - Step 03 - Primary and Qualifier - Which Spring Annotation Should You Use? - Step 04 - Exploring Spring Framework - Different Types of Dependency Injection - Step 05 - Java Spring Framework - Understanding Important Terminology - Step 06 - Java Spring Framework - Comparing @Component vs @Bean - Step 07 - Why do we have dependencies in Java Spring Applications? - Step 08 - Exercise/ Solution for Real World Java Spring Framework Example - Step 09 - Exploring Spring Framework With Java - Section 2 - Review ### Exploring Spring Framework Advanced Features - Step 01 - Exploring Lazy and Eager Initialization of Spring Framework Beans - Step 02 - Comparing Lazy Initialization vs Eager Initialization - Step 03 - Exploring Java Spring Framework Bean Scopes - Prototype and Singleton - Step 04 - Comparing Prototype vs Singleton - Spring Framework Bean Scopes - Step 05 - Exploring Spring Beans - PostConstruct and PreDestroy - Step 06 - Evolution of Jakarta EE - Comparing with J2EE and Java EE - Step 07 - Exploring Jakarta CDI with Spring Framework and Java - Step 08 - Exploring Java Spring XML Configuration - Step 09 - Exploring Java Annotations vs XML Configuration for Java Spring Framework - Step 10 - Exploring Spring Framework Stereotype Annotations - Component and more - Step 11 - Quick Review - Important Spring Framework Annotations - Step 12 - Quick Review - Important Spring Framework Concepts - Step 13 - Exploring Spring Big Picture - Framework, Modules and Projects ### Getting Started with Spring Boot - Step 01 - Getting Started with Spring Boot - Goals - Step 02 - Understanding the World Before Spring Boot - 10000 Feet Overview - Step 03 - Setting up New Spring Boot Project with Spring Initializr - Step 04 - Build a Hello World API with Spring Boot - Step 05 - Understanding the Goal of Spring Boot - Step 06 - Understanding Spring Boot Magic - Spring Boot Starter Projects - Step 07 - Understanding Spring Boot Magic - Auto Configuration - Step 08 - Build Faster with Spring Boot DevTools - Step 09 - Get Production Ready with Spring Boot - 1 - Profiles - Step 10 - Get Production Ready with Spring Boot - 2 - ConfigurationProperties - Step 11 - Get Production Ready with Spring Boot - 3 - Embedded Servers - Step 12 - Get Production Ready with Spring Boot - 4 - Actuator - Step 13 - Understanding Spring Boot vs Spring vs Spring MVC - Step 14 - Getting Started with Spring Boot - Review ### Getting Started with JPA and Hibernate with Spring and Spring Boot - Step 01 - Getting Started with JPA and Hibernate - Goals - Step 02 - Setting up New Spring Boot Project for JPA and Hibernate - Step 03 - Launching up H2 Console and Creating Course Table in H2 - Step 04 - Getting Started with Spring JDBC - Step 05 - Inserting Hardcoded Data using Spring JDBC - Step 06 - Inserting and Deleting Data using Spring JDBC - Step 07 - Querying Data using Spring JDBC - Step 08 - Getting Started with JPA and EntityManager - Step 09 - Exploring the Magic of JPA - Step 10 - Getting Started with Spring Data JPA - Step 11 - Exploring features of Spring Data JPA - Step 12 - Understanding difference between Hibernate and JPA ### Build Java Web Application with Spring Framework, Spring Boot and Hibernate - Step 00 - Introduction to Building Web App with Spring Boot - Step 01 - Creating Spring Boot Web Application with Spring Initializr - Step 02 - Quick overview of Spring Boot Project - Step 03 - First Spring MVC Controller, @ResponseBody, @Controller - Step 04 - 01 - Enhancing Spring MVC Controller to provide HTML response - Step 04 - 02 - Exploring Step By Step Coding and Debugging Guide - Step 05 - Redirect to a JSP using Spring Boot - Controller, @ResponseBody and View Resolver - Step 06 - Exercise - Creating LoginController and login view - Step 07 - Quick Overview - How does web work - Request and Response - Step 08 - Capturing QueryParams using RequestParam and First Look at Model - Step 09 - Quick Overview - Importance of Logging with Spring Boot - Step 10 - Understanding DispatcherServlet, Model 1, Model 2 and Front Controller - Step 11 - Creating a Login Form - Step 12 - Displaying Login Credentials in a JSP using Model - Step 13 - Add hard coded validation of userid and password - Step 14 - Getting started with Todo Features - Creating Todo and TodoService - Step 15 - Creating first version of List Todos Page - Step 16 - Understanding Session vs Model vs Request - @SessionAttributes - Step 17 - Adding JSTL to Spring Boot Project and Showing Todos in a Table - Step 18 - Adding Bootstrap CSS framework to Spring Boot Project using webjars - Step 19 - Formatting JSP pages with Bootstrap CSS framework - Step 20 - Lets Add a New Todo - Create a new View - Step 21 - Enhancing TodoService to add the todo - Step 22 - Adding Validations using Spring Boot Starter Validation - Step 23 - Using Command Beans to implement New Todo Page Validations - Step 24 - Implementing Delete Todo Feature - New View - Step 25 - Implementing Update Todo - 1 - Show Update Todo Page - Step 26 - Implementing Update Todo - 1 - Save changes to Todo - Step 27 - Adding Target Date Field to Todo Page - Step 28 - Adding a Navigation Bar and Implementing JSP Fragments - Step 29 - Preparing for Spring Security - Step 30 - Setting up Spring Security with Spring Boot Starter Security - Step 31 - Configuring Spring Security with Custom User and Password Encoder - Step 32 - Refactoring and Removing Hardcoding of User Id - Step 33 - Setting up a New User for Todo Application - Step 34 - Adding Spring Boot Starter Data JPA and Getting H2 database ready - Step 35 - 01 - Configuring Spring Security to Get H2 console Working - Step 36 - Making Todo an Entity and Population Todo Data into H2 - Step 37 - Creating TodoRepository and Connecting List Todos page from H2 database - Step 38 - 01 - Connecting All Todo App Features to H2 Database - Step 38 - 02 - Exploring Magic of Spring Boot Starter JPA and JpaRepository - Step 39 - OPTIONAL - Overview of Connecting Todo App to MySQL database - Step 40 - OPTIONAL - Installing Docker - Step 41 - OPTIONAL - Connecting Todo App to MySQL database ### Creating a Java REST API with Spring Boot, Spring Framework and Hibernate - Step 00 - Creating a REST API with Spring Boot - An Overview - Step 01 - Initializing a REST API Project with Spring Boot - Step 02 - Creating a Hello World REST API with Spring Boot - Step 03 - Enhancing the Hello World REST API to return a Bean - Step 04 - What's happening in the background? Spring Boot Starters and Autoconfiguration - Step 05 - Enhancing the Hello World REST API with a Path Variable - Step 06 - Designing the REST API for Social Media Application - Step 07 - Creating User Bean and UserDaoService - Step 08 - Implementing GET Methods for User Resource - Step 09 - Implementing POST Method to create User Resource - Step 10 - Enhancing POST Method to return correct HTTP Status Code and Location URI - Step 11 - Implementing Exception Handling - 404 Resource Not Found - Step 12 - Implementing Generic Exception Handling for all Resources - Step 13 - Implementing DELETE Method to delete a User Resource - Step 14 - Implementing Validations for REST API - Step 15 - Overview of Advanced REST API Features - Step 16 - Understanding Open API Specification and Swagger - Step 17 - Configuring Auto Generation of Swagger Documentation - Step 18 - Exploring Content Negotiation - Implementing Support for XML - Step 19 - Exploring Internationalization for REST API - Step 20 - Versioning REST API - URI Versioning - Step 21 - Versioning REST API - Request Param, Header and Content Negotiation - Step 22 - Implementing HATEOAS for REST API - Step 23 - Implementing Static Filtering for REST API - Step 24 - Implementing Dynamic Filtering for REST API - Step 25 - Monitoring APIs with Spring Boot Actuator - Step 26 - Exploring APIs with Spring Boot HAL Explorer - Step 27 - Connecting REST API to H2 using JPA and Hibernate - An Overview - Step 28 - Creating User Entity and some test data - Step 29 - Enhancing REST API to connect to H2 using JPA and Hibernate - Step 30 - Creating Post Entity with Many to One Relationship with User Entity - Step 31 - Implementing a GET API to retrieve all Posts of a User - Step 32 - Implementing a POST API to create a Post for a User - Step 33 - Exploring JPA and Hibernate Queries for REST API - Step 34 - Connecting REST API to MySQL Database - An Overview - Step 34z - OPTIONAL - Installing Docker - Step 35 - OPTIONAL - Connecting REST API to MySQL Database - Implementation - Step 36 - Implementing Basic Authentication with Spring Security - Step 37 - Enhancing Spring Security Configuration for Basic Authentication ### Building Java Full Stack Application with Spring Boot and React - Step 01 - Getting Started - Full Stack Spring Boot and React Application - Step 02 - Exploring What and Why of Full Stack Architectures - Step 03 - Understanding JavaScript and EcmaScript History - Step 04 - Installing Visual Studio Code - Step 05 - Installing nodejs and npm - Step 06 - Creating React App with Create React App - Step 07 - Exploring Important nodejs Commands - Create React App - Step 08 - Exploring Visual Studio Code and Create React App - Step 09 - Exploring Create React App Folder Structure - Step 10 - Getting started with React Components - Step 11 - Creating Your First React Component and more - Step 12 - Getting Started with State in React - useState hook - Step 13 - Exploring JSX - React Views - Step 14 - Following JavaScript Best Practices - Refactoring to Modules - Step 15 - Exploring JavaScript further ### Exploring React Components with Counter Example - Step 01 - Exploring React Components with Counter Example - Step 02 - Getting Started with React Application - Counter - Step 03 - Getting Started with React Application - Counter - 2 - Step 04 - Exploring React State with useState hook - Adding state to Counter - Step 05 - Exploring React State - What is happening in Background? - Step 06 - Exploring React Props - Setting Counter increment value - Step 07 - Creating Multiple Counter Buttons - Step 08 - Moving React State Up - Setting up Counter and Counter Button - Step 09 - Moving React State Up - Calling Parent Component Methods - Step 10 - Exploring React Developer Tools - Step 11 - Adding Reset Button to Counter - Step 12 - Refactoring React Counter Component ### Building Java Todo Full Stack Application with Spring Boot and React - Step 01 - Getting Started with React Todo Management App - Step 02 - Getting Started with Login Component - Todo React App - Step 03 - Improving Login Component Further - Todo React App - Step 04 - Adding Hardcoded Authentication - Todo React App - Step 05 - Conditionally Displaying Messages in Login Component - Todo React App - Step 06 - Adding React Router Dom and Routing from Login to Welcome Component - Step 07 - Adding Error Component to our React App - Step 08 - Removing Hard Coding from Welcome Component - Step 09 - Getting Started with React List Todo Component - Step 10 - Displaying More Todo Details in React List Todo Component - Step 11 - Creating React Header, Footer and Logout Components - Step 12 - Adding Bootstrap to React Front End Application - Step 13 - Using Bootstrap to Style Todo React Front End Application - Step 14 - Refactoring React Components to Individual JavaScript Modules - Step 15 - Sharing React State with Multiple Components with Auth Context - Step 16 - Updating React State and Verifying Updates through Auth Context - Step 17 - Setting isAuthenticated into React State - Auth Context - Step 18 - Protecting Secure React Routes using Authenticated Route - 1 - Step 19 - Protecting Secure React Routes using Authenticated Route - 2 ### Connecting Spring Boot REST API with React Frontend - Java Full Stack Application - Step 01 - Setting Todo REST API Project for React Full Stack Application - Step 02 - Calling Spring Boot Hello World REST API from React Hello World Component - Step 03 - Enabling CORS Requests for Spring Boot REST API - Step 04 - Invoking Spring Boot Hello World Bean and Path Param REST API from React - Step 05 - Refactoring Spring Boot REST API Invocation Code to New Module - Step 06 - Following Axios Best Practices in Spring Boot REST API - Step 07 - Creating Retrieve Todos Spring Boot REST API Get Method - Step 08 - Displaying Todos from Spring Boot REST API in React App - Step 09 - Creating Retrieve Todo and Delete Todo Spring Boot REST API Methods - Step 10 - Adding Delete Feature to React Frontend - Step 11 - Setting Username into React Auth Context - Step 12 - Creating Todo React Component to display Todo Page - Step 13 - Adding Formik and Moment Libraries to Display Todo React Component - Step 14 - Adding Validation to Todo React Component using Formik - Step 15 - Adding Update Todo and Create Todo REST API to Spring Boot Backend API - Step 16 - Adding Update Feature to React Frontend - Step 17 - Adding Create New Todo Feature to React Frontend - Step 18 - Securing Spring Boot REST API with Spring Security - Step 19 - Adding Authorization Header in React to Spring Boot REST API calls - Step 20 - Configuring Spring Security to allow all Options Requests - Step 21 - Calling Basic Authentication Service when Logging into React App - Step 22 - Using async and await to invoke Basic Auth API - Step 23 - Setting Basic Auth Token into Auth Context - Step 24 - Setting up Axios Interceptor to add Authorization Header - Step 24A - Debugging Problems with Basic Auth and Spring Boot - Step 25 - Getting Started with JWT and Spring Security - Step 26 - Integrating Spring Security JWT REST API with React Frontend - Step 27 - Debugging Problems with JWT Auth and Spring Boot ### Connecting Java Full Stack Application (Spring Boot and React) with JPA and Hibernate - Step 01 - Full Stack React and Spring Boot with JPA and Hibernate - Step 02 - Full Stack React & Spring Boot with JPA & Hibernate - Getting Tables Ready - Step 03 - Full Stack React & Spring Boot with JPA & Hibernate - Todo CRUD operations - Step 04 - Full Stack React & Spring Boot with JPA & Hibernate - Add New Todo - Step 05 - Full Stack React & Spring Boot with JPA & Hibernate - Connect with MySQL ### Exploring Unit Testing with JUnit - Step 01 - What is JUnit and Unit Testing_ - Step 02 - Your First JUnit Project and Green Bar - Step 03 - Your First Code and First Unit Test - Step 04 - Exploring other assert methods - Step 05 - Exploring few important JUnit annotations ### Exploring Mocking with Mockito for Spring Boot Projects - Step 00 - Introduction to Section - Mockito in 5 Steps - Step 01 - Setting up a Spring Boot Project - Step 02 - Understanding problems with Stubs - Step 03 - Writing your first Mockito test with Mocks - Step 04 - Simplifying Tests with Mockito Annotations - @Mock, @InjectMocks - Step 05 - Exploring Mocks further by Mocking List interface ### Securing Spring Boot Applications with Spring Security - Step 00 - Getting started with Spring Security - Step 01 - Understanding Security Fundamentals - Step 02 - Understanding Security Principles - Step 03 - Getting Started with Spring Security - Step 04 - Exploring Default Spring Security Configuration - Step 05 - Creating Spring Boot Project for Spring Security - Step 06 - Exploring Spring Security - Form Authentication - Step 07 - Exploring Spring Security - Basic Authentication - Step 08 - Exploring Spring Security - Cross Site Request Forgery - CSRF - Step 09 - Exploring Spring Security - CSRF for REST API - Step 10 - Creating Spring Security Configuration to Disable CSRF - Step 11 - Exploring Spring Security - Getting Started with CORS - Step 12 - Exploring Spring Security - Storing User Credentials in memory - Step 13 - Exploring Spring Security - Storing User Credentials using JDBC - Step 14 - Understanding Encoding vs Hashing vs Encryption - Step 15 - Exploring Spring Security - Storing Bcrypt Encoded Passwords - Step 16 - Getting Started with JWT Authentication - Step 17 - Setting up JWT Auth with Spring Security and Spring Boot - 1 - Step 18 - Setting up JWT Auth with Spring Security and Spring Boot - 2 - Step 19 - Setting up JWT Resource with Spring Security and Spring Boot - 1 - Step 20 - Setting up JWT Resource with Spring Security and Spring Boot - 2 - Step 21 - Understanding Spring Security Authentication - Step 22 - Exploring Spring Security Authorization - Step 23 - Creating a Spring Boot Project for OAuth with Spring Security - Step 24 - Getting Started with Spring Boot and OAuth2 - Login with Google - Step 25 - Quick Review - Securing Spring Boot Apps with Spring Security ### Learning Spring AOP with Spring Boot - Step 01 - Getting Started with Spring AOP - An overview - Step 02 - What is Aspect Oriented Programming? - Step 03 - Creating a Spring Boot Project for Spring AOP - Step 04 - Setting up Spring Components for Spring AOP - Step 05 - Creating AOP Logging Aspect and Pointcut - Step 06 - Understanding AOP Terminology - Step 07 - Exploring @After, @AfterReturning, @AfterThrowing AOP Annotations - Step 08 - Exploring Around AOP annotations with a Timer class - Step 09 - AOP Best Practice - Creating Common Pointcut Definitions - Step 10 - Creating Track Time Annotation - Step 11 - Getting Started with Spring AOP - Thank You ### Learning Maven with Spring and Spring Boot - Step 01 - Introduction to Maven - Step 02 - Creating a Spring Boot Project with Maven - Step 03 - Exploring Maven pom.xml for Spring Boot Project - Step 04 - Exploring Maven Parent Pom for Spring Boot Project - Step 05 - Exploring Maven Further - Step 06 - Exploring Maven Build Lifecycle with a Spring Boot Project - Step 07 - How does Maven Work? - Step 08 - Playing with Maven Commands - Step 09 - How are Spring Projects Versioned? ### Learning Gradle with Spring and Spring Boot - Step 01 - Getting Started with Gradle - Step 02 - Creating a Spring Boot Project with Gradle - Step 03 - Exploring Gradle Build and Settings Files - Step 04 - Exploring Gradle Plugins for Java and Spring Boot - Step 05 - Maven or Gradle - Which one to use for Spring Boot Projects? ### Learning Docker with Spring and Spring Boot - Step 01 - Getting Started with Docker - Step 02 - Understanding Docker Fundamentals - Step 03 - Understanding How Docker Works - Step 04 - Understanding Docker Terminology - Step 05 - Creating Docker Image for a Spring Boot Project - Dockerfile - Step 06 - Building Spring Boot Docker Image using Multi Stage Dockerfile - Step 07 - Building Spring Boot Docker Image - Optimizing Dockerfile - Step 08 - Building Docker Image with Spring Boot Maven Plugin - Step 09 - Quick Review of Docker with Spring Boot ### Getting Started with Cloud and AWS - Step 02 - Introduction to Cloud and AWS - Advantages - Step 03 - Creating Your AWS Account - Step 04 - Creating Your First IAM User - Step 05 - Understanding the Need for Regions and Zones - Step 06 - Exploring Regions and Availability Zones in AWS ### Getting Started with Compute Services in AWS - Step 01 - Getting Started with EC2 - Virtual Servers in AWS - Step 02 - Demo - Creating Virtual Machines with Amazon EC2 - Step 02z - Demo - Setting up a Web Server in an Amazon EC2 Instance - Step 03 - Quick Review of Important EC2 Concepts - Step 04 - Exploring IaaS vs PaaS - Cloud Computing with AWS - Step 05 - Getting Started with AWS Elastic Beanstalk - Step 06 - Demo - Setting up Web Application with AWS Elastic Beanstalk - Step 07 - Demo - Playing with AWS Elastic Beanstalk - Step 08 - Understanding the Need for Docker and Containers - Step 09 - Exploring Container Orchestration in AWS - Step 10 - Demo - Setting up ECS Cluster with AWS Fargate - Step 11 - Demo - Playing with Amazon ECS - Step 12 - Getting Started with Serverless in AWS - AWS Lambda - Step 13 - Demo - Creating Your First Lambda Function - Step 14 - Demo - Playing with Lambda Functions - Step 15 - Cloud Computing in AWS - Quick Review of Compute Services ### Deploying Spring Boot Applications to AWS - Step 01 - Deploying Hello World Spring Boot App to AWS - Step 02 - Exploring AWS Elastic Beanstalk - Your First Spring Boot App in AWS - Step 03 - Running Spring Boot REST API with MySQL Database as Docker Container - Step 04 - Deploying Spring Boot REST API with MySQL to AWS Elastic Beanstalk and RDS - Step 05 - Exploring AWS Elastic Beanstalk and Amazon RDS - Spring Boot REST API - Step 06 - Exploring Spring Boot and React Full Stack App - Step 07 - Deploying Full Stack Spring Boot REST API to AWS Elastic Beanstalk - Step 08 - Deploying Full Stack React App to Amazon S3 ### Introduction to Functional Programming with Java - Step 00 - Introduction to Functional Programming - Overview - Step 01 - Getting Started with Functional Programming with Java - Step 02 - Writing Your First Java Functional Program - Step 03 - Improving Java Functional Program with filter - Step 04 - Using Lambda Expression to enhance your Functional Program - Step 05 - Do Functional Programming Exercises with Streams, Filters and Lambdas - Step 06 - Using map in Functional Programs - with Exercises - Step 07 - Understanding Optional class in Java - Step 08 - Quick Review of Functional Programming Basics ### Congratulations - Master Spring Framework and Spring Boot - Congratulations - Master Spring Framework and Spring Boot
1
sivaprasadreddy/springboot-kubernetes-youtube-series
Code for SpringBoot + Kubernetes Tutorial" YouTube Series"
null
# springboot-kubernetes-youtube-series Code for "SpringBoot + Kubernetes Tutorial" YouTube Series https://www.youtube.com/playlist?list=PLuNxlOYbv61h66_QlcjCEkVAj6RdeplJJ > **NOTE:** > The original code that is explained in the YouTube video series is available in the `youtube-video-version` branch. > The code in the `main` branch is updated to use the latest versions of the dependencies. ## How to run? ```shell $ git clone https://github.com/sivaprasadreddy/springboot-kubernetes-youtube-series.git $ cd springboot-kubernetes-youtube-series $ ./run.sh start $ ./run.sh stop $ ./run.sh start_infra $ ./run.sh stop_infra ``` * To start only dependent services ```shell $ ./run.sh start_infra $ ./run.sh stop_infra ``` ## Running on Kubernetes ```shell $ cd springboot-kubernetes-youtube-series $ cd kind $ ./create-cluster.sh $ cd ../ $ kubectl apply -f k8s/ ``` * Access API using NodePort http://localhost:18080/api/bookmarks * Access UI using NodePort http://localhost:30080/ * Access API using Ingress http://localhost/bookmarker-api/api/bookmarks * Access UI using Ingress http://localhost/ ## Kubernetes Useful commands ### Pods ```shell kubectl get pods kubectl get all kubectl run bookmarker-api --image=sivaprasadreddy/bookmarker-api --restart=Never --port=8080 --labels=env=dev,version=1.0 kubectl get all kubectl describe pods bookmarker-api kubectl delete pods bookmarker-api kubectl run bookmarker-api --image=sivaprasadreddy/bookmarker-api --restart=Never --port=8080 --labels=env=dev,version=1.0 --dry-run=client -o yaml > pod.yaml kubectl apply -f pod.yaml kubectl logs bookmarker-api -f kubectl exec -it bookmarker-api -- /bin/sh kubectl delete -f pod.yaml kubectl get ns kubectl create ns dev kubectl run bookmarker-api --image=sivaprasadreddy/bookmarker-api --restart=Never --port=8080 -n dev -o yaml --dry-run=client > pod.yaml kubectl get pods -n dev kubectl delete ns dev ``` ### Deployments ```shell kubectl create deployment bookmarker-api-deploy --image=sivaprasadreddy/bookmarker-api kubectl create deployment bookmarker-api-deploy --image=sivaprasadreddy/bookmarker-api --dry-run=client -o yaml > deployment.yaml kubectl describe deployments.apps/bookmarker-api-deploy kubectl rollout history deployments bookmarker-api-deploy kubectl scale deployment bookmarker-api-deploy --replicas=3 kubectl set image deployment bookmarker-api-deploy bookmarker-api=sivaprasadreddy/bookmarker-api:1.1 kubectl rollout status deployment bookmarker-api-deploy kubectl rollout undo deployment bookmarker-api-deploy --to-revision=1 ``` ### ConfigMaps & Secrets ```shell kubectl create configmap db-config --from-literal=db_host=postgres --from-literal=db_name=appdb kubectl create configmap db-config --from-env-file=config.env kubectl create configmap db-config --from-file=config.txt kubectl create configmap db-config --from-file=app-config kubectl describe configmaps db-config kubectl get configmaps db-config -o yaml kubectl create secret generic db-creds --from-literal=pwd=s3cret kubectl create secret generic db-creds --from-env-file=secret.env kubectl create secret generic ssh-key --from-file=id_rsa=~/.ssh/id_rsa echo -n 's3cret!' | base64 kubectl get secret db-creds ``` ### Services * **ClusterIP**: Exposes the Service on a cluster-internal IP. Only reachable from within the cluster. * **NodePort**: Exposes the Service on each node's IP address at a static port. Accessible from outside of the cluster. * **LoadBalancer**: Exposes the Service externally using a cloud provider's load balancer. * **ExternalName**: Maps a Service to a DNS name. ```shell kubectl expose deployment bookmarker-api-deploy --port=8080 --target-port=8080 --type=NodePort ```
0
maxithub/reactive-spring-tutorial
This is the tutorial for Reactive Programming and Spring Framework
null
# Getting Started This repository for the demo code of my **Reactive Spring Tutorial**, which contains a series of sessions about: * Reactive Programming * Project Reactor * Spring WebFlux * Spring R2DS * Spring Security * Spring Cloud Load Balancer * Spring Cloud Circuit Breaker * Spring Cloud Gateway # 视频教程地址 1. [Reactive Spring 教程 #1 - Reactive Programming简介](https://www.bilibili.com/video/BV1fz411t7aP/),包含以下内容: * 函数式编程 * Java 8中的Stream API * 什么是响应式编程 * 为什么要学响应式编程 * Spring框架中响应式编程 [脑图地址](https://naotu.baidu.com/file/fdf212e8578525af3bd0f3d39b7fe0c7?token=03aaac593d5a9a4d) 2. [Reactive Spring 教程 #2 - Reactor API使用](https://www.bilibili.com/video/BV1XC4y1s7su/),主要讲解一下Sping Project Reactor API的使用。 3. [Reactive Spring 教程 #3 - WebMVC对比WebFlux(上)](https://www.bilibili.com/video/BV12g4y187UG/),主要讲解一下Sping WebFlux对比Spring MVC的使用。 4. [Reactive Spring 教程 #4 - WebMVC对比WebFlux(中)](https://www.bilibili.com/video/BV1Dg4y1z7YK/),主要讲解一下Sping WebFlux对比Spring MVC的使用,完成典型CRUD endpoint的实现。 5. [Reactive Spring 教程 #5 - WebMVC对比WebFlux(下)](https://www.bilibili.com/video/BV1Kk4y1k7Cy/),主要讲解一下怎样通过Sping WebFlux中的WebClient的调用HTTP API,和一些简单的异常处理。 6. [Reactive Spring 教程 #6 - 响应式高吞吐关系型数据库访问](https://www.bilibili.com/video/BV1Lz411q7sG/),主要讲解一下怎样通过Sping R2DBC进行响应式(非阻塞式)的数据库操作,和事务处理。 7. [Reactive Spring 教程 #7 - Reactive Spring Security](https://www.bilibili.com/video/BV1rT4y1u71V/),主要讲解一下Spring Security框架在Reactive方面的更新。 8. [Reactive Spring 教程 #8 - 响应式高吞吐负载均衡](https://www.bilibili.com/video/BV14A411q7oF/),主要讲解一下Spring Cloud框架的响应式高吞吐负载均衡。 9. [Reactive Spring 教程 #9 - 响应式服务熔断](https://www.bilibili.com/video/BV1HQ4y1P7u3/),主要讲解如何使用Spring Cloud Circuit Break + Resilience4j 框架进行响应式服务的服务熔断,和一些可以用在生产环境的配置技巧。 10. [Reactive Spring 教程 #10 - 高并发响应式网关Spring Cloud Gateway](https://www.bilibili.com/video/BV1nD4y1Q7c5/),主要讲解如何使用Spring Cloud Gateway框架进行响应式API网关、负载均衡和熔断。 11. [Reactive Spring 教程 #11 - 如何编写单元测试](https://www.bilibili.com/video/BV12t4y197fv/),主要讲解如何Reactive Spring框架下编写单元测试代码。 12. [Reactive Spring 教程 #12 - 线程模型](https://www.bilibili.com/video/BV11K411H7BC/),主要讲解如何Reactive Spring框架下做阻塞型或CPU密集型的任务,并行处理。 13. [Reactive Spring 教程 #13 - 何时该用响应式开发](https://www.bilibili.com/video/BV1M54y1q79q/),主要讲解Reactive Spring的优劣,和什么时候应该考虑使用响应式编程,什么情况下要避免强推。
1
whtoo/How_to_implment_PL_in_Antlr4
简明自制编程语言教程,同时是antlr非官方参考🌰。这里也是cyson这门语言的缘起。
antlr4 compiler-construction java-17 tutorials
# 从解释计算的视角:如何亲手创造一门编程语言Cyson **每一个watch和star都是这场梦幻之旅的⛽️与干柴** [![Security Status](https://www.murphysec.com/platform3/v31/badge/1718907022023983104.svg)](https://www.murphysec.com/console/report/1718907021914931200/1718907022023983104) **兴❤️如🔥,其势如风.意许如油,汩汩不息。** ## 1. 全局鸟瞰 - [x] [ep1](ep1)--antlr支持的EBNF语法描述hello world示例。 - [x] [ep2](ep2)--如何使用g4描述形如`{1,2,{3,4..}...}`的数组,并在listener中print它。 - [x] [ep3](ep3)--实现一个只包含加减乘除的微型计算器。 - [x] [ep4](ep4)--实现一个可以进行简单交互的算术计算器。 - [x] [ep5](ep5)--实现一个Java接口提取工具。 - [x] [ep6](ep6)--实现一个CVS提取器。 - [x] [ep7](ep7)--实现一个JSON解析工具。 - [x] [ep8](ep8)--抽象语法书提取器 - [x] [ep9](ep9)--ep4增强版本 - [x] [ep10](ep10)--ep6的另一种实现 - [x] [ep11](ep11)--基于ep8的算术解释器(AST Tree walking) - [x] [ep12](ep12)--ep11增加赋值语句和变量声明。 - [x] [ep13](ep13)--ep11另一种简化实现。 - [x] [ep14](ep14)--实现符号表记录。 - [x] [ep15](ep15)--实现变量的作用域确定。 - [x] [ep16](ep16)--实现变量的消解和类型检查,并实现函数作用域与有函数调用的脚本求值。 - [x] [ep17](ep17)--实现函数的静态声明依赖(并不是我心里想的调用图生成,但是还是加上吧,让其他人避坑。) - [x] [ep18](ep18)--采用栈解释器,目前很简陋。增加VM指令,更新[VM设计文档](src%2Forg%2Fteachfx%2Fantlr4%2Fep18%2FVM_Design.md) - [x] [ep19](ep19)--实现简单的struct(~~实现闭包~~),目前实现了最简单的record类型和main函数以及file作用域~~下一章增加类方法和协议支持~~。 - [x] [ep20](ep20)--重点放在IR和字节码生成,生成的字节码目标机就是我们[ep18](ep18)实现的VM。这么做的原因是这个过程足够简单、精确地表现编译后端中最重要的一步是如何执行的。 - [ ] [ep21](ep21)--TAC生成、SSA与CFG。[__WIP__] -------------------- ### 番外 ❤️👀: 终于写完了,感觉好忐忑。不过,我还有另外几个也是编译原理相关的坑也要填。 首先,我得感谢父母,他们给了我莫大支持。 其次,感谢我自己和我的妻子,如果不是我们的相遇我永远也不能写完。 最后,感谢这个时代,我需要的一切都在这个时候刚刚好到来。 -------------------- ## 2. 为什么会有这个系列的教程? 我从开始编程就一直在想,如果我是一个意图规划者, 而不是人肉编码器该有多好。 因此,我一头扎进了编程语言构造和分析的汪洋大海中去捞 那根我心中的定海神针。 现在,我真正走进了编译后端处理和程序分析后,我感到自己 有太多想记录的知识、技能、想法,以及创造好用的新工具和新过程。 所以,这就是我的起点,希望你能和我一样享受这个过程。 ## 3. 工程体系介绍 整个工程需要3种外部环境支持。 - a. `JDK18+` is required. (JDK环境需要>= 18,我本地是openJDK 18) - b. `Antlr4` runtime support.(lib已经有了,并且我在ant构建文件中已经写好了。) - c. `Ant` support. (Mac:brew install ant,其他平台:[Baidu一下Ant安装](https://www.baidu.com/s?wd=ant%E5%AE%89%E8%A3%85&rsv_spt=1&rsv_iqid=0x92a5c3ca00098ab3&issp=1&f=8&rsv_bp=1&rsv_idx=2&ie=utf-8&rqlang=cn&tn=baiduhome_pg&rsv_enter=1&rsv_dl=tb&oq=ant&rsv_btype=t&inputT=1837&rsv_t=ec4cvoU9XIugnSk4yfAeGzHEthu95IAGc%2BcxFt188XBik9tpLDQyKTb2S3Y4301WBs3T&rsv_pq=ea06018e001299b9&rsv_sug3=50&rsv_sug1=21&rsv_sug7=100&rsv_sug2=0&rsv_sug4=2109))。 ### 3.1. 目录如下所述: - `src`: the folder to maintain sources * `org/teachfx/antlr4` -- top package name. * `ep${num}` -- `num` in `{1,2,3,...,25}` * current `num` is `20` - `lib`: the folder to maintain dependencies ### 3.2. 从哪儿开始? 当所有依赖都安装完毕后,以ep20为例 ```Bash cd your_project_dir cd ep20 ant gen ant run ``` ### 3.3. 如何从Ant构建并运行工程 这部分就是Ant的一般使用,我之前是参考《Ant使用指南》--一本很老的书。 大家可以百度一下,教程很多我就不浪费篇幅了。 ## 4. 参考或者模仿材料来源 ### 4.1 如何解释一个程序 - [计算机程序的构造和解释(SICP)](https://www.zhihu.com/topic/19620884/hot) - [动手做解释器](http://www.craftinginterpreters.com/) ### 4.2 如何实现一个计算器 - [如何实现一个编程语言](http://lisperator.net/pltut/) - [编程语言的实现模式](https://www.zhihu.com/topic/20116185/hot) - [Antlr4权威指南](https://www.antlr.org/) - [自顶向下算符优先分析(TDOP)](https://github.com/douglascrockford/TDOP) - [编译原理(龙术:smile:)](https://www.zhihu.com/question/21549783/answer/22749476)
0
thegreystone/jmc-tutorial
A hands-on-lab/tutorial for learning JDK Mission Control 7+.
hacktoberfest hacktoberfest2021
# JDK Mission Control Tutorial This tutorial provides plenty of examples and material to help you learn JDK Mission Control (7+). ## Preparations Since it is not practical to pre-package everything required to run the material here at GitHub, there are some preparations required before starting the Tutorial. ### Setting up the JDK You will need to have a JDK 11 or later to do this tutorial. You can either use the [Oracle JDK](http://java.oracle.com) or any OpenJDK build, for example the one provided by [Oracle](http://jdk.java.net/11/). You will need to ensure that `java` for your JDK is on your path, and you should also make sure that your JAVA_HOME variable is set to the parent folder of the `bin` folder containing your `java` binary. ### Getting the stand alone version of JMC There are various binary builds of JMC available. See the JMC github repo for alternatives (any will do): https://github.com/openjdk/jmc#readme ### Setting up Eclipse The tutorial will be easier to run if you have an Eclipse installed. You will need an Eclipse Oxygen 4.8.0 or later. You will also need to add some VM arguments. For example: ```ini -vmargs -Djdk.attach.allowAttachSelf=true --add-exports=java.xml/com.sun.org.apache.xerces.internal.parsers=ALL-UNNAMED --add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED --add-exports=java.management/sun.management=ALL-UNNAMED --add-exports=java.management/sun.management.counter.perf=ALL-UNNAMED --add-exports=jdk.management.agent/jdk.internal.agent=ALL-UNNAMED --add-exports=jdk.attach/sun.tools.attach=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=jdk.attach/sun.tools.attach=ALL-UNNAMED ``` Depending on your platform you will also need to add one final export. If running on Windows, also add: ```ini --add-exports=java.desktop/sun.awt.windows=ALL-UNNAMED ``` If running on Mac OS, also add: ```ini --add-exports=java.desktop/sun.lwawt.macosx=ALL-UNNAMED ``` If running on Linux, also add: ```ini --add-exports=java.desktop/sun.awt.X11=ALL-UNNAMED ``` You may also want to ensure that your newly setup JDK is being used for running Eclipse. This can be enforced by using the -vm option in the eclipse.ini file. Don't forget that the -vmargs option must be last in the file. For example: ```ini -vm /Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home/bin -vmargs -Djdk.attach.allowAttachSelf=true ... ``` #### Adding the Eclipse plug-ins Next you will want to add the JMC plug-ins. You can either get the update site pre-built from AdoptOpenJDK (https://adoptopenjdk.net/jmc), or build it yourself. Install git (if you don't already have it) and run the following command in the folder you wish to clone the JMC source: ```bash git clone https://github.com/openjdk/jmc ``` Follow the instructions in the README.md found in the root of the JMC repository on how to create and access the update sites for Eclipse. #### Importing the projects To import the projects into Eclipse, create a new Workspace and simply import all the projects available in the projects folder. ## Running the Tutorial The [tutorial instructions](https://github.com/thegreystone/jmc-tutorial/tree/master/docs) explain in detail how to run the JMC labs. If running the labs from within Eclipse, first ensure that you have set up an Eclipse properly, added the plug-in version of JMC, and imported the projects. ## About This tutorial is for learning how to use JDK Mission Contol. It is provided under GPLv3 as is. If you find a problem, please open a ticket or feel free to provide a pull request.
0
archerImagine/HeadFirstJava
This is a repository for the following tutorials Head First Java by Kathy Sierra and Bert Bates.
null
HeadFirstJava ============= This is a repository for the following tutorials Head First Java by Kathy Sierra and Bert Bates. **Kathy Sierra** - **Bert Bates** - The solution and Practice of Second Edition **Head First Java**. Notes - 1. [Chapter 01](src/head/first/java/chapter01/Chapter01.md) 2. [Chapter 02](src/head/first/java/chapter02/Readme.md) 3. [Chapter 03](src/head/first/java/chapter03/Readme.md) 4. [Chapter 04](src/head/first/java/chapter04/Readme.md) 5. [Chapter 05](src/head/first/java/chapter05/Readme.md) 6. [Chapter 06](src/head/first/java/chapter06/Readme.md) 7. [Chapter 07](src/head/first/java/chapter07/Readme.md) 8. [Chapter 08](src/head/first/java/chapter08/Readme.md) 9. [Chapter 09](src/head/first/java/chapter09/Readme.md) 10. [Chapter 10](src/head/first/java/chapter10/Readme.md) 11. [Chapter 11](src/head/first/java/chapter11/Readme.md) 12. [Chapter 12](src/head/first/java/chapter12/Readme.md) 13. [Chapter 13](src/head/first/java/chapter13/Readme.md) 14. [Chapter 14](src/head/first/java/chapter14/Readme.md) 15. [Chapter 15](src/head/first/java/chapter15/Readme.md) 16. [Chapter 16](src/head/first/java/chapter16/Readme.md) 17. [Chapter 17](src/head/first/java/chapter17/Readme.md)
0
wpcfan/spring-boot-tut
My Spring Boot Tutorial -- Focusing on minimizing the learning curve and get personal thoughts about dev involved all over the tutorial. Spring Boot教程,一个掺杂着个人学习经验的不断生长的教程。
null
# 重拾后端之Spring Boot(一):REST API的搭建可以这样简单 标签(空格分隔): 未分类 --- ![Spring Boot][1] 话说我当年接触Spring的时候着实兴奋了好一阵,IoC的概念当初第一次听说,感觉有种开天眼的感觉。记得当时的web框架和如今的前端框架的局面差不多啊,都是群雄纷争。但一晃好多年没写过后端,代码这东西最怕手生,所以当作重新学习了,顺便写个学习笔记。 ## Spring Boot是什么? 还恍惚记得当初写Spring的时候要配置好多xml(在当时还是相对先进的模式),虽然实现了松耦合,但这些xml却又成为了项目甩不掉的负担 -- 随着项目越做越大,这些xml的可读性和可维护性极差。后来受.Net平台中Annotation的启发,Java世界中也引入了元数据的修饰符,Spring也可以使用这种方式进行配置。到了近些年,随着Ruby on Rails的兴起而流行开的 `Convention over configuration` 理念开始深入人心。那什么是 `Convention over configuration` 呢?简单来说就是牺牲一部分的自由度来减少配置的复杂度,打个比方就是如果你如果遵从我定义的一系列规则(打个比方,文件目录结构必须是blablabla的样子,文件命名必须是nahnahnah 的样子),那么你要配置的东西就非常简单甚至可以零配置。既然已经做到这个地步了,各种脚手架项目就纷纷涌现了,目的只有一个:让你更专注在代码的编写,而不是浪费在各种配置上。这两年前端也有类似趋势,各种前端框架的官方CLI纷纷登场:create-react-app,angular-cli,vue-cli等等。 那么Spring Boot就是Spring框架的脚手架了,它可以帮你快速搭建、发布一个Spring应用。官网列出了Spring Boot的几个主要目标 - 提供一种快速和广泛适用的Spring开发体验 - 开箱即用却又可以适应各种变化 - 提供一系列开发中常用的“非功能性”的特性(比如嵌入式服务器、安全、度量、自检及外部配置等) - 不生成任何代码,不需要xml配置 ## 安装Spring Boot 官方推荐的方式是通过sdkman( http://sdkman.io/install.html )来进行安装,当然这是对 `*nix` 而言。题外话,如果你使用的是Windows 10,真心希望大家安装Windows 10的Linux子系统,微软官方出品、原生支持,比虚拟机不知道快到那里去了 具体安装过程可以参考 https://linux.cn/article-7209-1.html 。安装 `sdkman` 的步骤非常简单,就两步: 1. 打开一个terminal,输入 `curl -s "https://get.sdkman.io" | bash` 2. 安装结束后,重启terminal,输入 `source "$HOME/.sdkman/bin/sdkman-init.sh"` 可以在terminal中验证一下是否安装成功 `sdk version`,如果你看到了版本号就是安装好了。 接下来,就可以安装Spring Boot了,还是打开terminal输入 `sdk install springboot`就ok了。 当然其实Mac的童鞋可以省略掉之前的sdkman安装直接使用 `brew` 安装,也是两步: 1. 在terminal中输入 `brew tap pivotal/tap` 2. 然后 `brew install springboot` 验证的话可以输入 `spring --version` 看看是否正常输出了版本号。 ## 创建一个工程 有很多种方法可以创建一个Spring Boot项目,其中最简单的一种是通过一个叫Spring Initializr的在线工具 `http://start.spring.io/` 进行工程的生成。如下图所示,只需填写一些参数就可以生成一个工程包了。 ![使用Spring Initializr进行工程的生成][2] 如果你使用Intellij IDEA进行开发,里面也集成了这个工具,大家可以自行尝试。 ![Intellij IDEA中集成了 Spring Initializr ][3] 但下面我们要做的不是通过这种方式,而是手动的通过命令行方式创建。创建的是gradle工程,而不是maven的,原因呢是因为个人现在对于xml类型的配置文件比较无感;-),官方推荐使用gradle 2.14.1版本,请自行安装gradle。下面来建立一个gradle工程,其实步骤也不算太难: 1. 新建一个工程目录 `mkdir task` 2. 在此目录下使用gradle进行初始化 `gradle init`(就和在node中使用 `npm init` 的效果类似) 这个命令帮我们建立一个一个使用gradle进行管理的模版工程: - `build.gradle`:有过Android开发经验的童鞋可能觉得很亲切的,这个就是我们用于管理和配置工程的核心文件了。 - `gradlew`:用于 `*nix` 环境下的gradle wrapper文件。 - `gradlew.bat`:用于 `Windows` 环境下的gradle wrapper文件 - `setting.gradle`:用于管理多项目的gradle工程时使用,单项目时可以不做理会。 - gradle目录:wrapper的jar和属性设置文件所在的文件夹。 简单说两句什么是 `gradle wrapper`。你是否有过这样的经历?在安装/编译一个工程时需要一些先决条件,需要安装一些软件或设置一些参数。如果这一切比较顺利还好,但很多时候我们会发现这样那样的问题,比如版本不对,参数没设置等等。`gradle wrapper` 就是这样一个让你不会浪费时间在配置问题上的方案。它会对应一个开发中使用的gradle版本,以确保任何人任何时候得到的结果是一致的。 - `./gradlew <task>`: 在 `*nix` 平台上运行,例如Linux或Mac OS X - `gradlew <task>` 在Windows平台运行(是通过`gradlew.bat`来执行的) 更多关于wrapper的知识可以去 https://docs.gradle.org/current/userguide/gradle_wrapper.html 查看。 那么下面我们打开默认生成的 `build.gradle` 文件,将其改造成下面的样子: ```gradle /* * 这个build文件是由Gradle的 `init` 任务生成的。 * * 更多关于在Gradle中构建Java项目的信息可以查看Gradle用户文档中的 * Java项目快速启动章节 * https://docs.gradle.org/3.3/userguide/tutorial_java_projects.html */ // 在这个段落中你可以声明你的build脚本需要的依赖和解析下载该依赖所使用的仓储位置 // 如果遇到下载速度慢的话可以换成阿里镜像 // maven {url "http://maven.aliyun.com/nexus/content/repositories/central/"} buildscript { ext { springBootVersion = '1.4.3.RELEASE' } repositories { mavenCentral() } dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") } } /* * 在这个段落中你可以声明使用哪些插件 * apply plugin: 'java' 代表这是一个Java项目,需要使用java插件 * 如果想生成一个 `Intellij IDEA` 的工程,类似的如果要生成 * eclipse工程,就写 apply plugin: 'eclipse' * 同样的我们要学的是Spring Boot,所以应用Spring Boot插件 */ apply plugin: 'java' apply plugin: 'idea' apply plugin: 'eclipse' apply plugin: 'org.springframework.boot' // 在这个段落中你可以声明编译后的Jar文件信息 jar { baseName = 'task' version = '0.0.1-SNAPSHOT' } // 在这个段落中你可以声明在哪里可以找到你的项目依赖 repositories { // 使用 'jcenter' 作为中心仓储查询解析你的项目依赖。 // 你可以声明任何 Maven/Ivy/file 类型的依赖类库仓储位置 // 如果遇到下载速度慢的话可以换成阿里镜像 // maven {url "http://maven.aliyun.com/nexus/content/repositories/central/"} mavenCentral() } // 在这个段落中你可以声明源文件和目标编译后的Java版本兼容性 sourceCompatibility = 1.8 targetCompatibility = 1.8 // 在这个段落你可以声明你的项目的开发和测试所需的依赖类库 dependencies { compile('org.springframework.boot:spring-boot-starter-web') testCompile('org.springframework.boot:spring-boot-starter-test') } ``` 首先脚本依赖中的 `spring-boot-gradle-plugin` 有什么作用呢?它提供了以下几个功能: 1. 简化执行和发布:它可以把所有classpath的类库构建成一个单独的可执行jar文件,这样可以简化你的执行和发布等操作。 2. 自动搜索入口文件:它会扫描 `public static void main()` 函数并且标记这个函数的宿主类为可执行入口。 3. 简化依赖:一个典型的Spring应用还是需要很多依赖类库的,想要配置正确这些依赖挺麻烦的,所以这个插件提供了内建的依赖解析器会自动匹配和当前Spring Boot版本匹配的依赖库版本。 在最后一个段落中,我们看到我们的项目依赖两个类库,一个是 `spring-boot-starter-web` ,另一个是 `spring-boot-starter-test`。Spring Boot提供了一系列依赖类库的“模版”,这些“模版”封装了很多依赖类库,可以让我们非常方便的引用自己想实现的功能所需要的类库。如果我们去看看这个 `spring-boot-starter-web` 中究竟引用了什么,我们可以看看它的artifact文件(到 http://search.maven.org/ 可以查看): ```xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starters</artifactId> <version>1.4.3.RELEASE</version> </parent> <artifactId>spring-boot-starter-web</artifactId> <name>Spring Boot Web Starter</name> <description>Starter for building web, including RESTful, applications using Spring MVC. Uses Tomcat as the default embedded container</description> <url>http://projects.spring.io/spring-boot/</url> <organization> <name>Pivotal Software, Inc.</name> <url>http://www.spring.io</url> </organization> <properties> <main.basedir>${basedir}/../..</main.basedir> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator</artifactId> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> </dependency> </dependencies> </project> ``` ## IDE支持 一般做Java开发,大部分团队还是喜欢用一个IDE,虽然我还是更偏爱文本编辑器类型的(比如sublime,vscode,atom等)。但是如果非挑一个重型IDE的话,我更喜欢Intellij IDEA。 使用IDEA的import project功能选中 `build.gradle`,将工程导入。由于是个gradle工程,请把 `View->Tools Window->Gradle` 的视图窗口调出来。 ![Gradle工具窗口][4] 点击左上角的刷新按钮可以将所有依赖下载类库下来。注意IDEA有时提示是否要配置wrapper使用带源码的gradle包。 ![提示使用带源码的gradle以便有API的文档][5] 如果遇到不知道什么原因导致一直刷新完成不了的情况,请在项目属性中选择 `Use local gradle distribution` ![image_1b77vqast1d2h1qioeepsdm1tkb9.png-192.5kB][6] ## 第一个Web API ### 领域对象 那么我们的源代码目录在哪里呢?我们得手动建立一个,这个目录一般情况下是 `src/main/java`。好的,下面我们要开始第一个RESTful的API搭建了,首先还是在 `src/main/java` 下新建一个 `package`。既然是本机的就叫 `dev.local` 吧。我们还是来尝试建立一个 Todo 的Web API,在 `dev.local` 下建立一个子 `package`: `task`,然后创建一个Todo的领域对象: ```java package dev.local.task; /** * Todo是一个领域对象(domain object) * Created by wangpeng on 2017/1/24. */ public class Todo { private String id; private String desc; private boolean completed; public String getId() { return id; } public void setId(String id) { this.id = id; } public String getDesc() { return desc; } public void setDesc(String desc) { this.desc = desc; } public boolean isCompleted() { return completed; } public void setCompleted(boolean completed) { this.completed = completed; } } ``` 这个对象很简单,只是描述了todo的几个属性: `id` 、 `desc` 和 `completed` 。我们的API返回或接受的参数就是以这个对象为模型的类或集合。 ### 构造Controller 我们经常看到的RESTful API是这样的:`http://local.dev/todos`、`http://local.dev/todos/1` 。Controller就是要暴露这样的API给外部使用。现在我们同样的在 `task` 下建立一个叫 `TodoController` 的java文件 ```java package dev.local.task; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.ArrayList; import java.util.List; /** * 使用@RestController来标记这个类是个Controller */ @RestController public class TodoController { // 使用@RequstMapping指定可以访问的URL路径 @RequestMapping("/todos") public List<Todo> getAllTodos() { List<Todo> todos = new ArrayList<>(); Todo item1 = new Todo(); item1.setId("1"); item1.setCompleted(false); item1.setDesc("go swimming"); todos.add(item1); Todo item2 = new Todo(); item2.setId("1"); item2.setCompleted(true); item2.setDesc("go for lunch"); todos.add(item2); return todos; } } ``` 上面这个文件也比较简单,但注意到以下几个事情: - `@RestController` 和 `@RequestMapping` 这两个是元数据注释,原来在.Net中很常见,后来Java也引进过来。一方面它们可以增加代码的可读性,另一方面也有效减少了代码的编写。具体机理就不讲了,简单来说就是利用Java的反射机制和IoC模式结合把注释的特性或属性注入到被注释的对象中。 - 我们看到 `List<Todo> getAllTodos()` 方法中简单的返回了一个List,并未做任何转换成json对象的处理,这个是Spring会自动利用 ` Jackson` 这个类库的方法将其转换成了json。 我们到这就基本接近成功了,但是现在缺少一个入口,那么在 `dev.local` 包下面建立一个 `Applicaiton.java` 吧。 ```java package dev.local; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; /** * Spring Boot 应用的入口文件 * Created by wangpeng on 2017/1/24. */ @SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } } ``` 同样的我们只需标注这个类是 `@SpringBootApplication` 就万事大吉了。可以使用下面任意一种方法去启动我们的Web服务: 1. 命令行中: `./gradlew bootRun` 2. IDEA中在 `Application` 中右键选择 `Run 'Application'` ![IDE中右键启动应用][7] 启动后,打开浏览器访问 `http://localhost:8080/todos` 就可以看到我们的json形式的返回结果了。 ![浏览器直接访问一下的效果][8] ## 配置Spring Beans工具 由于使用的是Spring框架,Spring工具窗口也是需要的,一般来说如果你安装了Spring插件的话,IDEA会自动探测到你的项目是基于Spring的。一般在你增加了Applicaiton入口后,会提示是否添加context。 ![检测到Spring配置,但提示尚未关联][9] 遇到这种情况,请点提示框的右方的下箭头展开提示。 ![展开后的提示框][10] 点击 `Create Default Context` 会将目前的所有没有map的Spring配置文件都放在这个默认配置的上下文中。在Spring的工具窗口中可以看到下图效果。 ![创建Spring配置的默认上下文][11] 本章代码:https://github.com/wpcfan/spring-boot-tut/tree/chap01 # 重拾后端之Spring Boot(二):MongoDB的无缝集成 上一节,我们做的那个例子有点太简单了,通常的后台都会涉及一些数据库的操作,然后在暴露的API中提供处理后的数据给客户端使用。那么这一节我们要做的是集成MongoDB ( https://www.mongodb.com )。 ## MongoDB是什么? MongoDB是一个NoSQL数据库,是NoSQL中的一个分支:文档数据库。和传统的关系型数据库比如Oracle、SQLServer和MySQL等有很大的不同。传统的关系型数据库(RDBMS)已经成为数据库的代名词超过20多年了。对于大多数开发者来说,关系型数据库是比较好理解的,表这种结构和SQL这种标准化查询语言毕竟是很大一部分开发者已有的技能。那么为什么又搞出来了这个什么劳什子NoSQL,而且看上去NoSQL数据库正在飞快的占领市场。 ### NoSQL的应用场景是什么? 假设说我们现在要构建一个论坛,用户可以发布帖子(帖子内容包括文本、视频、音频和图片等)。那么我们可以画出一个下图的表关系结构。 ![论坛的简略ER图][12] 这种情况下我们想一下这样一个帖子的结构怎么在页面中显示,如果我们希望显示帖子的文字,以及关联的图片、音频、视频、用户评论、赞和用户的信息的话,我们需要关联八个表取得自己想要的数据。如果我们有这样的帖子列表,而且是随着用户的滚动动态加载,同时需要监听是否有新内容的产生。这样一个任务我们需要太多这种复杂的查询了。 NoSQL解决这类问题的思路是,干脆抛弃传统的表结构,你不是帖子有一个结构关系吗,那我就直接存储和传输一个这样的数据给你,像下面那样。 ```json { "id":"5894a12f-dae1-5ab0-5761-1371ba4f703e", "title":"2017年的Spring发展方向", "date":"2017-01-21", "body":"这篇文章主要探讨如何利用Spring Boot集成NoSQL", "createdBy":User, "images":["http://dev.local/myfirstimage.png","http://dev.local/mysecondimage.png"], "videos":[ {"url":"http://dev.local/myfirstvideo.mp4", "title":"The first video"}, {"url":"http://dev.local/mysecondvideo.mp4", "title":"The second video"} ], "audios":[ {"url":"http://dev.local/myfirstaudio.mp3", "title":"The first audio"}, {"url":"http://dev.local/mysecondaudio.mp3", "title":"The second audio"} ] } ``` NoSQL一般情况下是没有Schema这个概念的,这也给开发带来较大的自由度。因为在关系型数据库中,一旦Schema确定,以后更改Schema,维护Schema是很麻烦的一件事。但反过来说Schema对于维护数据的完整性是非常必要的。 一般来说,如果你在做一个Web、物联网等类型的项目,你应该考虑使用NoSQL。如果你要面对的是一个对数据的完整性、事务处理等有严格要求的环境(比如财务系统),你应该考虑关系型数据库。 ## 在Spring中集成MongoDB 在我们刚刚的项目中集成MongoDB简单到令人发指,只有三个步骤: 1. 在 `build.gradle` 中更改 `compile('org.springframework.boot:spring-boot-starter-web')` 为 `compile("org.springframework.boot:spring-boot-starter-data-rest")` 2. 在 `Todo.java` 中给 `private String id;` 之前加一个元数据修饰 `@Id` 以便让Spring知道这个Id就是数据库中的Id 2. 新建一个如下的 `TodoRepository.java` ```java package dev.local.task; import org.springframework.data.mongodb.repository.MongoRepository; import org.springframework.data.rest.core.annotation.RepositoryRestResource; @RepositoryRestResource(collectionResourceRel = "task", path = "task") public interface TodoRepository extends MongoRepository<Todo, String>{ } ``` 此时我们甚至不需要Controller了,所以暂时注释掉 `TodoController.java` 中的代码。然后我们 `./gradlew bootRun` 启动应用。访问 `http://localhost:8080/task` 我们会得到下面的的结果。 ```json { _embedded: { task: [ ] }, _links: { self: { href: "http://localhost:8080/task" }, profile: { href: "http://localhost:8080/profile/task" } }, page: { size: 20, totalElements: 0, totalPages: 0, number: 0 } } ``` 我勒个去,不光是有数据集的返回结果 `task: [ ]` ,还附赠了一个links对象和page对象。如果你了解 `Hypermedia` 的概念,就会发现这是个符合 `Hypermedia` REST API返回的数据。 说两句关于 `MongoRepository<Todo, String>` 这个接口,前一个参数类型是领域对象类型,后一个指定该领域对象的Id类型。 ### Hypermedia REST 简单说两句Hypermedia是什么。简单来说它是可以让客户端清晰的知道自己可以做什么,而无需依赖服务器端指示你做什么。原理呢,也很简单,通过返回的结果中包括不仅是数据本身,也包括指向相关资源的链接。拿上面的例子来说(虽然这种默认状态生成的东西不是很有代表性):links中有一个profiles,我们看看这个profile的链接 `http://localhost:8080/profile/task` 执行的结果是什么: ```json { "alps" : { "version" : "1.0", "descriptors" : [ { "id" : "task-representation", "href" : "http://localhost:8080/profile/task", "descriptors" : [ { "name" : "desc", "type" : "SEMANTIC" }, { "name" : "completed", "type" : "SEMANTIC" } ] }, { "id" : "create-task", "name" : "task", "type" : "UNSAFE", "rt" : "#task-representation" }, { "id" : "get-task", "name" : "task", "type" : "SAFE", "rt" : "#task-representation", "descriptors" : [ { "name" : "page", "doc" : { "value" : "The page to return.", "format" : "TEXT" }, "type" : "SEMANTIC" }, { "name" : "size", "doc" : { "value" : "The size of the page to return.", "format" : "TEXT" }, "type" : "SEMANTIC" }, { "name" : "sort", "doc" : { "value" : "The sorting criteria to use to calculate the content of the page.", "format" : "TEXT" }, "type" : "SEMANTIC" } ] }, { "id" : "patch-task", "name" : "task", "type" : "UNSAFE", "rt" : "#task-representation" }, { "id" : "update-task", "name" : "task", "type" : "IDEMPOTENT", "rt" : "#task-representation" }, { "id" : "delete-task", "name" : "task", "type" : "IDEMPOTENT", "rt" : "#task-representation" }, { "id" : "get-task", "name" : "task", "type" : "SAFE", "rt" : "#task-representation" } ] } } ``` 这个对象虽然我们暂时不是完全的理解,但大致可以猜出来,这个是todo这个REST API的元数据描述,告诉我们这个API中定义了哪些操作和接受哪些参数等等。我们可以看到todo这个API有增删改查等对应功能。 其实呢,Spring是使用了一个叫 `ALPS` (http://alps.io/spec/index.html) 的专门描述应用语义的数据格式。摘出下面这一小段来分析一下,这个描述了一个get方法,类型是 `SAFE` 表明这个操作不会对系统状态产生影响(因为只是查询),而且这个操作返回的结果格式定义在 `task-representation` 中了。 `task-representation` ```json { "id" : "get-task", "name" : "task", "type" : "SAFE", "rt" : "#task-representation" } ``` 还是不太理解?没关系,我们再来做一个实验,启动 PostMan (不知道的同学,可以去Chrome应用商店中搜索下载)。我们用Postman构建一个POST请求: ![用Postman构建一个POST请求添加一个Todo][13] 执行后的结果如下,我们可以看到返回的links中包括了刚刚新增的Todo的link `http://localhost:8080/task/588a01abc5d0e23873d4c1b8` ( `588a01abc5d0e23873d4c1b8` 就是数据库自动为这个Todo生成的Id),这样客户端可以方便的知道指向刚刚生成的Todo的API链接。 ![执行添加Todo后的返回Json数据][14] 再举一个现实一些的例子,我们在开发一个“我的”页面时,一般情况下除了取得我的某些信息之外,因为在这个页面还会有一些可以链接到更具体信息的页面链接。如果客户端在取得比较概要信息的同时就得到这些详情的链接,那么客户端的开发就比较简单了,而且也更灵活了。 其实这个描述中还告诉我们一些分页的信息,比如每页20条记录(`size: 20`)、总共几页(`totalPages:1`)、总共多少个元素(`totalElements: 1`)、当前第几页(`number: 0`)。当然你也可以在发送API请求时,指定page、size或sort参数。比如 `http://localhost:8080/todos?page=0&size=10` 就是指定每页10条,当前页是第一页(从0开始)。 ### 魔法的背后 这么简单就生成一个有数据库支持的REST API,这件事看起来比较魔幻,但一般这么魔幻的事情总感觉不太托底,除非我们知道背后的原理是什么。首先再来回顾一下 `TodoRepository` 的代码: ```java @RepositoryRestResource(collectionResourceRel = "task", path = "task") public interface TodoRepository extends MongoRepository<Todo, String>{ } ``` Spring是最早的几个IoC(控制反转或者叫DI)框架之一,所以最擅长的就是依赖的注入了。这里我们写了一个Interface,可以猜到Spring一定是有一个这个接口的实现在运行时注入了进去。如果我们去 `spring-data-mongodb` 的源码中看一下就知道是怎么回事了,这里只举一个小例子,大家可以去看一下 `SimpleMongoRepository.java` ( [源码链接][15] ),由于源码太长,我只截取一部分: ```java public class SimpleMongoRepository<T, ID extends Serializable> implements MongoRepository<T, ID> { private final MongoOperations mongoOperations; private final MongoEntityInformation<T, ID> entityInformation; /** * Creates a new {@link SimpleMongoRepository} for the given {@link MongoEntityInformation} and {@link MongoTemplate}. * * @param metadata must not be {@literal null}. * @param mongoOperations must not be {@literal null}. */ public SimpleMongoRepository(MongoEntityInformation<T, ID> metadata, MongoOperations mongoOperations) { Assert.notNull(mongoOperations); Assert.notNull(metadata); this.entityInformation = metadata; this.mongoOperations = mongoOperations; } public <S extends T> S save(S entity) { Assert.notNull(entity, "Entity must not be null!"); if (entityInformation.isNew(entity)) { mongoOperations.insert(entity, entityInformation.getCollectionName()); } else { mongoOperations.save(entity, entityInformation.getCollectionName()); } return entity; } ... public T findOne(ID id) { Assert.notNull(id, "The given id must not be null!"); return mongoOperations.findById(id, entityInformation.getJavaType(), entityInformation.getCollectionName()); } private Query getIdQuery(Object id) { return new Query(getIdCriteria(id)); } private Criteria getIdCriteria(Object id) { return where(entityInformation.getIdAttribute()).is(id); } ... } ``` 也就是说其实在运行时Spring将这个类或者其他具体接口的实现类注入了应用。这个类中有支持各种数据库的操作。我了解到这步就觉得ok了,有兴趣的同学可以继续深入研究。 虽然不想在具体类上继续研究,但我们还是应该多了解一些关于 `MongoRepository` 的东西。这个接口继承了 `PagingAndSortingRepository` (定义了排序和分页) 和 `QueryByExampleExecutor`。而 `PagingAndSortingRepository` 又继承了 `CrudRepository` (定义了增删改查等)。 第二个魔法就是 `@RepositoryRestResource(collectionResourceRel = "task", path = "task")` 这个元数据的修饰了,它直接对MongoDB中的集合(本例中的todo)映射到了一个REST URI(task)。因此我们连Controller都没写就把API搞出来了,而且还是个Hypermedia REST。 其实呢,这个第二个魔法只在你需要变更映射路径时需要。本例中如果我们不加 `@RepositoryRestResource` 这个修饰符的话,同样也可以生成API,只不过其路径按照默认的方式变成了 `todoes` ,大家可以试试把这个元数据修饰去掉,然后重启服务,访问 `http://localhost:8080/todoes` 看看。 说到这里,顺便说一下REST的一些约定俗成的规矩。一般来说如果我们定义了一个领域对象 (比如我们这里的Todo),那么这个对象的集合(比如Todo的列表)可以使用这个对象的命名的复数方式定义其资源URL,也就是刚刚我们访问的 `http://localhost:8080/todoes`,对于新增一个对象的操作也是这个URL,但Request的方法是POST。 而这个某个指定的对象(比如指定了某个ID的Todo)可以使用 `todoes/:id` 来访问,比如本例中 `http://localhost:8080/todoes/588a01abc5d0e23873d4c1b8`。对于这个对象的修改和删除使用的也是这个URL,只不过HTTP Request的方法变成了PUT(或者PATCH)和DELETE。 这个里面默认采用的这个命名 `todoes` 是根据英语的语法来的,一般来说复数是加s即可,但这个todo,是辅音+o结尾,所以采用的加es方式。 `task` 其实并不是一个真正意义上的单词,所以我认为更合理的命名方式应该是 `todos`。所以我们还是改成 `@RepositoryRestResource(collectionResourceRel = "todos", path = "todos")` ## 无招胜有招 刚才我们提到的都是开箱即用的一些方法,你可能会想,这些东西看上去很炫,但没有毛用,实际开发过程中,我们要使用的肯定不是这么简单的增删改查啊。说的有道理,我们来试试看非默认方法。那么我们就来增加一个需求,我们可以通过查询Todo的描述中的关键字来搜索符合的项目。 显然这个查询不是默认的操作,那么这个需求在Spring Boot中怎么实现呢?非常简单,只需在 `TodoRepository` 中添加一个方法: ```java ... public interface TodoRepository extends MongoRepository<Todo, String>{ List<Todo> findByDescLike(@Param("desc") String desc); } ``` 太不可思议了,这样就行?不信可以启动服务后,在浏览器中输入 `http://localhost:8080/todos/search/findByDescLike?desc=swim` 去看看结果。是的,我们甚至都没有写这个方法的实现就已经完成了该需求(题外话,其实 `http://localhost:8080/todos?desc=swim` 这个URL也起作用)。 你说这里肯定有鬼,我同意。那么我们试试把这个方法改个名字 `findDescLike` ,果然不好用了。为什么呢?这套神奇的疗法的背后还是那个我们在第一篇时提到的 `Convention over configuration`,要神奇的疗效就得遵循Spring的配方。这个配方就是方法的命名是有讲究的:Spring提供了一套可以通过命名规则进行查询构建的机制。这套机制会把方法名首先过滤一些关键字,比如 `find…By`, `read…By`, `query…By`, `count…By` 和 `get…By` 。系统会根据关键字将命名解析成2个子语句,第一个 `By` 是区分这两个子语句的关键词。这个 `By` 之前的子语句是查询子语句(指明返回要查询的对象),后面的部分是条件子语句。如果直接就是 `findBy…` 返回的就是定义Respository时指定的领域对象集合(本例中的Todo组成的集合)。 一般到这里,有的同学可能会问 `find…By`, `read…By`, `query…By`, `get…By` 到底有什么区别啊?答案是。。。木有区别,就是别名,从下面的定义可以看到这几个东东其实生成的查询是一样的,这种让你不用查文档都可以写对的方式也比较贴近目前流行的自然语言描述风格(类似各种DSL)。 ```java private static final String QUERY_PATTERN = "find|read|get|query|stream"; ``` 刚刚我们实验了模糊查询,那如果要是精确查找怎么做呢,比如我们要筛选出已完成或未完成的Todo,也很简单: ```java List<Todo> findByCompleted(@Param("completed") boolean completed); ``` ### 嵌套对象的查询怎么搞? 看到这里你会问,这都是简单类型,如果复杂类型怎么办?嗯,好的,我们还是增加一个需求看一下:现在需求是要这个API是多用户的,每个用户看到的Todo都是他们自己创建的项目。我们新建一个User领域对象: ```java package dev.local.user; import org.springframework.data.annotation.Id; public class User { @Id private String id; private String username; private String email; //此处为节省篇幅省略属性的getter和setter } ``` 为了可以添加User数据,我们需要一个User的REST API,所以添加一个 `UserRepository` ```java package dev.local.user; import org.springframework.data.mongodb.repository.MongoRepository; public interface UserRepository extends MongoRepository<User, String> { } ``` 然后给 `Todo` 领域对象添加一个User属性。 ```java package dev.local.task; //省略import部分 public class Todo { //省略其他部分 private User user; public User getUser() { return user; } public void setUser(User user) { this.user = user; } } ``` 接下来就可以来把 `TodoRepository` 添加一个方法定义了,我们先实验一个简单点的,根据用户的email来筛选出这个用户的Todo列表: ```java public interface TodoRepository extends MongoRepository<Todo, String>{ List<Todo> findByUserEmail(@Param("userEmail") String userEmail); } ``` 现在需要构造一些数据了,你可以通过刚刚我们建立的API使用Postman工具来构造:我们这里创建了2个用户,以及一些Todo项目,分别属于这两个用户,而且有部分项目的描述是一样的。接下来就可以实验一下了,我们在浏览器中输入 `http://localhost:8080/todos/search/findByUserEmail?userEmail=peng@gmail.com` ,我们会发现返回的结果中只有这个用户的Todo项目。 ``` { "_embedded" : { "todos" : [ { "desc" : "go swimming", "completed" : false, "user" : { "username" : "peng", "email" : "peng@gmail.com" }, "_links" : { "self" : { "href" : "http://localhost:8080/todos/58908a92c5d0e2524e24545a" }, "task" : { "href" : "http://localhost:8080/todos/58908a92c5d0e2524e24545a" } } }, { "desc" : "go for walk", "completed" : false, "user" : { "username" : "peng", "email" : "peng@gmail.com" }, "_links" : { "self" : { "href" : "http://localhost:8080/todos/58908aa1c5d0e2524e24545b" }, "task" : { "href" : "http://localhost:8080/todos/58908aa1c5d0e2524e24545b" } } }, { "desc" : "have lunch", "completed" : false, "user" : { "username" : "peng", "email" : "peng@gmail.com" }, "_links" : { "self" : { "href" : "http://localhost:8080/todos/58908ab6c5d0e2524e24545c" }, "task" : { "href" : "http://localhost:8080/todos/58908ab6c5d0e2524e24545c" } } }, { "desc" : "have dinner", "completed" : false, "user" : { "username" : "peng", "email" : "peng@gmail.com" }, "_links" : { "self" : { "href" : "http://localhost:8080/todos/58908abdc5d0e2524e24545d" }, "task" : { "href" : "http://localhost:8080/todos/58908abdc5d0e2524e24545d" } } } ] }, "_links" : { "self" : { "href" : "http://localhost:8080/todos/search/findByUserEmail?userEmail=peng@gmail.com" } } } ``` 看到结果后我们来分析这个 `findByUserEmail` 是如何解析的:首先在 `By` 之后,解析器会按照 `camel` (每个单词首字母大写)的规则来分词。那么第一个词是 `User`,这个属性在 `Todo` 中有没有呢?有的,但是这个属性是另一个对象类型,所以紧跟着这个词的 `Email` 就要在 `User` 类中去查找是否有 `Email` 这个属性。聪明如你,肯定会想到,那如果在 `Todo` 类中如果还有一个属性叫 `userEmail` 怎么办?是的,这种情况下 `userEmail` 会被优先匹配,此时请使用 `_` 来显性分词处理这种混淆。也就是说如果我们的 `Todo` 类中同时有 `user` 和 `userEmail` 两个属性的情况下,我们如果想要指定的是 `user` 的 `email` ,那么需要写成 `findByUser_Email`。 还有一个问题,我估计很多同学现在已经在想了,那就是我们的这个例子中并没有使用 `user` 的 `id`,这不科学啊。是的,之所以没有在上面使用 `findByUserId` 是因为要引出一个易错的地方,下面我们来试试看,将 `TodoRepository` 的方法改成 ```java public interface TodoRepository extends MongoRepository<Todo, String>{ List<Todo> findByUserId(@Param("userId") String userId); } ``` 你如果打开浏览器输入 `http://localhost:8080/todos/search/findByUserId?userId=589089c3c5d0e2524e245458` (这里的Id请改成你自己mongodb中的user的id),你会发现返回的结果是个空数组。原因是虽然我们在类中标识 `id` 为 `String` 类型,但对于这种数据库自己生成维护的字段,它在MongoDB中的类型是ObjectId,所以在我们的接口定义的查询函数中应该标识这个参数是 `ObjectId`。那么我们只需要改动 `userId` 的类型为 `org.bson.types.ObjectId` 即可。 ```java package dev.local.task; import org.bson.types.ObjectId; import org.springframework.data.mongodb.repository.MongoRepository; import org.springframework.data.repository.query.Param; import org.springframework.data.rest.core.annotation.RepositoryRestResource; import java.util.List; @RepositoryRestResource(collectionResourceRel = "todos", path = "todos") public interface TodoRepository extends MongoRepository<Todo, String>{ List<Todo> findByUserId(@Param("userId") ObjectId userId); } ``` ### 再复杂一些行不行? 好吧,到现在我估计还有一大波攻城狮表示不服,实际开发中需要的查询比上面的要复杂的多,再复杂一些怎么办?还是用例子来说话吧,那么现在我们想要模糊搜索指定用户的Todo中描述的关键字,返回匹配的集合。这个需求我们只需改动一行,这个以命名规则为基础的查询条件是可以加 `And`、`Or` 这种关联多个条件的关键字的。 ```java List<Todo> findByUserIdAndDescLike(@Param("userId") ObjectId userId, @Param("desc") String desc); ``` 当然,还有其他操作符:`Between` (值在两者之间), `LessThan` (小于), `GreaterThan` (大于), `Like` (包含), `IgnoreCase` (b忽略大小写), `AllIgnoreCase` (对于多个参数全部忽略大小写), `OrderBy` (引导排序子语句), `Asc` (升序,仅在 `OrderBy` 后有效) 和 `Desc` (降序,仅在 `OrderBy` 后有效)。 刚刚我们谈到的都是对于查询条件子语句的构建,其实在 `By` 之前,对于要查询的对象也可以有限定的修饰词 `Distinct` (去重,如有重复取一个值)。比如有可能返回的结果有重复的记录,可以使用 `findDistinctTodoByUserIdAndDescLike`。 我可以直接写查询语句吗?几乎所有码农都会问的问题。当然可以咯,也是同样简单,就是给方法加上一个元数据修饰符 `@Query` ```java public interface TodoRepository extends MongoRepository<Todo, String>{ @Query("{ 'user._id': ?0, 'desc': { '$regex': ?1} }") List<Todo> searchTodos(@Param("userId") ObjectId userId, @Param("desc") String desc); } ``` 采用这种方式我们就不用按照命名规则起方法名了,可以直接使用MongoDB的查询进行。上面的例子中有几个地方需要说明一下 1. `?0` 和 `?1` 是参数的占位符,`?0` 表示第一个参数,也就是 `userId`;`?1` 表示第二个参数也就是 `desc`。 2. 使用`user._id` 而不是 `user.id` 是因为所有被 `@Id` 修饰的属性在Spring Data中都会被转换成 `_id` 3. MongoDB中没有关系型数据库的Like关键字,需要以正则表达式的方式达成类似的功能。 其实,这种支持的力度已经可以让我们写出相对较复杂的查询了。但肯定还是不够的,对于开发人员来讲,如果不给可以自定义的方式基本没人会用的,因为总有这样那样的原因会导致我们希望能完全掌控我们的查询或存储过程。但这个话题展开感觉就内容更多了,后面再讲吧。 本章代码:https://github.com/wpcfan/spring-boot-tut/tree/chap02 # 找回熟悉的Controller,Service ## Controller哪儿去了? 对于很多习惯了Spring开发的同学来讲,`Controller`,`Service`,`DAO` 这些套路突然间都没了会有不适感。其实呢,这些东西还在,只不过对于较简单的情景下,这些都变成了系统背后帮你做的事情。这一小节我们就先来看看如何将Controller再召唤回来。召唤回来的好处有哪些呢?首先我们可以自定义API URL的路径,其次可以对参数和返回的json结构做一定的处理。 如果要让 `TodoController` 可以和 `TodoRepository` 配合工作的话,我们当然需要在 `TodoController` 中需要引用 `TodoRepository`。 ```java public class TodoController { @Autowired private TodoRepository repository; //省略其它部分 } ``` `@Autowired` 这个修饰符是用于做依赖性注入的,上面的用法叫做 `field injection`,直接做类成员的注入。但Spring现在鼓励用构造函数来做注入,所以,我们来看看构造函数的注入方法: ```java public class TodoController { private TodoRepository repository; @Autowired public TodoController(TodoRepository repository){ this.repository = repository; } //省略其它部分 } ``` 当然我们为了可以让Spring知道这是一个支持REST API的 `Controller` ,还是需要标记其为 `@RestController`。由于默认的路径映射会在资源根用复数形式,由于todo是辅音后的o结尾,按英语习惯,会映射成 `todoes`。但这里用 `todos` 比 `todoes` 更舒服一些,所以我们再使用另一个 `@RequestMapping("/todos")` 来自定义路径。这个 `Controller` 中的其它方法比较简单,就是利用repository中的方法去增删改查即可。 ```java package dev.local.task; import org.bson.types.ObjectId; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.List; @RestController @RequestMapping("/todos") public class TodoController { private TodoRepository repository; @Autowired public TodoController(TodoRepository repository){ this.repository = repository; } @RequestMapping(method = RequestMethod.GET) public List<Todo> getAllTodos(@RequestHeader(value = "userId") String userId) { return repository.findByUserId(new ObjectId(userId)); } @RequestMapping(method = RequestMethod.POST) Todo addTodo(@RequestBody Todo addedTask) { return repository.insert(addedTask); } @RequestMapping(value = "/{id}", method = RequestMethod.GET) public Todo getTodo(@PathVariable String id) { return repository.findOne(id); } @RequestMapping(value = "/{id}", method = RequestMethod.PUT) Todo updateTodo(@PathVariable String id, @RequestBody Todo updatedTask) { updatedTask.setId(id); return repository.save(updatedTask); } @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) Todo removeTodo(@PathVariable String id) { Todo deletedTask = repository.findOne(id); repository.delete(id); return deletedTask; } } ``` 上面的代码中需要再说明几个要点: 1. 为什么在类上标记 `@RequestMapping("/todos")` 后在每个方法上还需要添加 `@RequestMapping`?类上面定义的 `@RequestMapping` 的参数会默认应用于所有方法,但如果我们发现某个方法需要有自己的特殊值时,就需要定义这个方法的映射参数。比如上面例子中 `addTodo`,路径也是 `todos`,但要求 Request的方法是 `POST`,所以我们给出了 `@RequestMapping(method = RequestMethod.POST)`。但 `getTodo` 方法的路径应该是 `todos/:id`,这时我们要给出 `@RequestMapping(value = "/{id}", method = RequestMethod.GET)` 2. 这些方法接受的参数也使用了各种修饰符,`@PathVariable` 表示参数是从路径中得来的,而 `@RequestBody` 表示参数应该从 Http Request的`body` 中解析,类似的 `@RequestHeader` 表示参数是 Http Request的Header中定义的。 在可以测试之前,我们还需要使用 `@Repository` 来标记 `TodoRepository`,以便于Spring可以在依赖注入时可以找到这个类。 ```java package dev.local.task; import org.bson.types.ObjectId; import org.springframework.data.mongodb.repository.MongoRepository; import org.springframework.stereotype.Repository; import java.util.List; /** * Created by wangpeng on 2017/1/26. */ @Repository public interface TodoRepository extends MongoRepository<Todo, String>{ List<Todo> findByUserId(ObjectId userId); } ``` 接下来就可以用PostMan做一下测试: ![测试一下Controller][16] ## Service呢?在哪里? 熟悉Spring的童鞋肯定会问,我们刚才的做法等于直接是Controller访问Data了,隔离不够啊。其实我觉得有很多时候,这种简单设计是挺好的,因为业务还没有到达那步,过于复杂的设计其实没啥太大意义。但这里我们还是一步步来实践一下,找回大家熟悉的感觉。 回到原来的熟悉模式再简单不过的,新建一个 `TodoService` 接口,定义一下目前的增删改查几个操作: ```java public interface TodoService { Todo addTodo(Todo task); Todo deleteTodo(String id); List<Todo> findAll(String userId); Todo findById(String id); Todo update(Todo task); } ``` 为预防我们以后使用 `MySQL` 等潜在的 “可扩展性”,我们给这个接口的实现命名为 `MongoTodoServiceImpl`,然后把 `Controller` 中的大部分代码拿过来改改就行了。当然为了系统可以找到这个依赖并注入需要的类中,我们标记它为 `@Service` ```java @Service public class MongoTodoServiceImpl implements TodoService{ private final TodoRepository repository; @Autowired MongoTodoServiceImpl(TodoRepository repository) { this.repository = repository; } @Override public Todo addTodo(Todo task) { return repository.insert(task); } @Override public Todo deleteTodo(String id) { Todo deletedTask = repository.findOne(id); repository.delete(id); return deletedTask; } @Override public List<Todo> findAll(String userId) { return repository.findByUserId(new ObjectId(userId)); } @Override public Todo findById(String id) { return repository.findOne(id); } @Override public Todo update(Todo task) { repository.save(task); return task; } } ``` 最后把Controller中的所有方法改为使用Service的简单调用就大功告成了。 ``` public class TodoController { private TodoService service; @Autowired public TodoController(TodoService service){ this.service = service; } @RequestMapping(method = RequestMethod.GET) public List<Todo> getAllTodos(@RequestHeader(value = "userId") String userId) { return service.findAll(userId); } @RequestMapping(method = RequestMethod.POST) Todo addTodo(@RequestBody Todo addedTask) { return service.addTodo(addedTask); } @RequestMapping(value = "/{id}", method = RequestMethod.GET) public Todo getTodo(@PathVariable String id) { return service.findById(id); } @RequestMapping(value = "/{id}", method = RequestMethod.PUT) Todo updateTodo(@PathVariable String id, @RequestBody Todo updatedTask) { updatedTask.setId(id); return service.update(updatedTask); } @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) Todo removeTodo(@PathVariable String id) { return service.deleteTodo(id); } } ``` 说实话如果每个简单类都这么写,我深深地赶脚背离了Spring Boot的意图,虽然你能举出1000个理由这么做有好处。类似的,DAO或DTO要写起来也很简单,但我还是建议在业务没有复杂之前还是享受Spring Boot带给我们的便利吧。 # 重拾后端之Spring Boot(四):使用JWT和Spring Security保护REST API 通常情况下,把API直接暴露出去是风险很大的,不说别的,直接被机器攻击就喝一壶的。那么一般来说,对API要划分出一定的权限级别,然后做一个用户的鉴权,依据鉴权结果给予用户开放对应的API。目前,比较主流的方案有几种: 1. 用户名和密码鉴权,使用Session保存用户鉴权结果。 2. 使用OAuth进行鉴权(其实OAuth也是一种基于Token的鉴权,只是没有规定Token的生成方式) 3. 自行采用Token进行鉴权 第一种就不介绍了,由于依赖Session来维护状态,也不太适合移动时代,新的项目就不要采用了。第二种OAuth的方案和JWT都是基于Token的,但OAuth其实对于不做开放平台的公司有些过于复杂。我们主要介绍第三种:JWT。 ## 什么是JWT? JWT是 `Json Web Token` 的缩写。它是基于 [RFC 7519][17] 标准定义的一种可以安全传输的 **小巧** 和 **自包含** 的JSON对象。由于数据是使用数字签名的,所以是可信任的和安全的。JWT可以使用HMAC算法对secret进行加密或者使用RSA的公钥私钥对来进行签名。 ### JWT的工作流程 下面是一个JWT的工作流程图。模拟一下实际的流程是这样的(假设受保护的API在`/protected`中) 1. 用户导航到登录页,输入用户名、密码,进行登录 2. 服务器验证登录鉴权,如果改用户合法,根据用户的信息和服务器的规则生成JWT Token 3. 服务器将该token以json形式返回(不一定要json形式,这里说的是一种常见的做法) 4. 用户得到token,存在localStorage、cookie或其它数据存储形式中。 5. 以后用户请求`/protected`中的API时,在请求的header中加入 `Authorization: Bearer xxxx(token)`。此处注意token之前有一个7字符长度的 `Bearer ` 6. 服务器端对此token进行检验,如果合法就解析其中内容,根据其拥有的权限和自己的业务逻辑给出对应的响应结果。 7. 用户取得结果 ![JWT工作流程图][18] 为了更好的理解这个token是什么,我们先来看一个token生成后的样子,下面那坨乱糟糟的就是了。 ``` eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJ3YW5nIiwiY3JlYXRlZCI6MTQ4OTA3OTk4MTM5MywiZXhwIjoxNDg5Njg0NzgxfQ.RC-BYCe_UZ2URtWddUpWXIp4NMsoeq2O6UF-8tVplqXY1-CI9u1-a-9DAAJGfNWkHE81mpnR3gXzfrBAB3WUAg ``` 但仔细看到的话还是可以看到这个token分成了三部分,每部分用 `.` 分隔,每段都是用 [Base64][19] 编码的。如果我们用一个Base64的解码器的话 ( https://www.base64decode.org/ ),可以看到第一部分 `eyJhbGciOiJIUzUxMiJ9` 被解析成了: ``` { "alg":"HS512" } ``` 这是告诉我们HMAC采用HS512算法对JWT进行的签名。 第二部分 `eyJzdWIiOiJ3YW5nIiwiY3JlYXRlZCI6MTQ4OTA3OTk4MTM5MywiZXhwIjoxNDg5Njg0NzgxfQ` 被解码之后是 ```json { "sub":"wang", "created":1489079981393, "exp":1489684781 } ``` 这段告诉我们这个Token中含有的数据声明(Claim),这个例子里面有三个声明:`sub`, `created` 和 `exp`。在我们这个例子中,分别代表着用户名、创建时间和过期时间,当然你可以把任意数据声明在这里。 看到这里,你可能会想这是个什么鬼token,所有信息都透明啊,安全怎么保障?别急,我们看看token的第三段 `RC-BYCe_UZ2URtWddUpWXIp4NMsoeq2O6UF-8tVplqXY1-CI9u1-a-9DAAJGfNWkHE81mpnR3gXzfrBAB3WUAg`。同样使用Base64解码之后,咦,这是什么东东 ``` D X DmYTeȧLUZcPZ0$gZAY_7wY@ ``` 最后一段其实是签名,这个签名必须知道秘钥才能计算。这个也是JWT的安全保障。这里提一点注意事项,由于数据声明(Claim)是公开的,千万不要把密码等敏感字段放进去,否则就等于是公开给别人了。 也就是说JWT是由三段组成的,按官方的叫法分别是header(头)、payload(负载)和signature(签名): ``` header.payload.signature ``` 头中的数据通常包含两部分:一个是我们刚刚看到的 `alg`,这个词是 `algorithm` 的缩写,就是指明算法。另一个可以添加的字段是token的类型(按RFC 7519实现的token机制不只JWT一种),但如果我们采用的是JWT的话,指定这个就多余了。 ``` { "alg": "HS512", "typ": "JWT" } ``` payload中可以放置三类数据:系统保留的、公共的和私有的: - 系统保留的声明(Reserved claims):这类声明不是必须的,但是是建议使用的,包括:iss (签发者), exp (过期时间), sub (主题), aud (目标受众)等。这里我们发现都用的缩写的三个字符,这是由于JWT的目标就是尽可能小巧。 - 公共声明:这类声明需要在 [IANA JSON Web Token Registry][20] 中定义或者提供一个URI,因为要避免重名等冲突。 - 私有声明:这个就是你根据业务需要自己定义的数据了。 签名的过程是这样的:采用header中声明的算法,接受三个参数:base64编码的header、base64编码的payload和秘钥(secret)进行运算。签名这一部分如果你愿意的话,可以采用RSASHA256的方式进行公钥、私钥对的方式进行,如果安全性要求的高的话。 ``` HMACSHA256( base64UrlEncode(header) + "." + base64UrlEncode(payload), secret) ``` ### JWT的生成和解析 为了简化我们的工作,这里引入一个比较成熟的JWT类库,叫 `jjwt` ( https://github.com/jwtk/jjwt )。这个类库可以用于Java和Android的JWT token的生成和验证。 JWT的生成可以使用下面这样的代码完成: ```java String generateToken(Map<String, Object> claims) { return Jwts.builder() .setClaims(claims) .setExpiration(generateExpirationDate()) .signWith(SignatureAlgorithm.HS512, secret) //采用什么算法是可以自己选择的,不一定非要采用HS512 .compact(); } ``` 数据声明(Claim)其实就是一个Map,比如我们想放入用户名,可以简单的创建一个Map然后put进去就可以了。 ```java Map<String, Object> claims = new HashMap<>(); claims.put(CLAIM_KEY_USERNAME, username()); ``` 解析也很简单,利用 `jjwt` 提供的parser传入秘钥,然后就可以解析token了。 ```java Claims getClaimsFromToken(String token) { Claims claims; try { claims = Jwts.parser() .setSigningKey(secret) .parseClaimsJws(token) .getBody(); } catch (Exception e) { claims = null; } return claims; } ``` JWT本身没啥难度,但安全整体是一个比较复杂的事情,JWT只不过提供了一种基于token的请求验证机制。但我们的用户权限,对于API的权限划分、资源的权限划分,用户的验证等等都不是JWT负责的。也就是说,请求验证后,你是否有权限看对应的内容是由你的用户角色决定的。所以我们这里要利用Spring的一个子项目Spring Security来简化我们的工作。 ## Spring Security Spring Security是一个基于Spring的通用安全框架,里面内容太多了,本文的主要目的也不是展开讲这个框架,而是如何利用Spring Security和JWT一起来完成API保护。所以关于Spring Secruity的基础内容或展开内容,请自行去官网学习( http://projects.spring.io/spring-security/ )。 ### 简单的背景知识 如果你的系统有用户的概念的话,一般来说,你应该有一个用户表,最简单的用户表,应该有三列:Id,Username和Password,类似下表这种 | ID | USERNAME | PASSWORD | |----|----------|----------| | 10 | wang | abcdefg | 而且不是所有用户都是一种角色,比如网站管理员、供应商、财务等等,这些角色和网站的直接用户需要的权限可能是不一样的。那么我们就需要一个角色表: | ID | ROLE | |----|------| | 10 | USER | | 20 | ADMIN | 当然我们还需要一个可以将用户和角色关联起来建立映射关系的表。 | USER_ID | ROLE_ID | |----|------| | 10 | 10 | | 20 | 20 | 这是典型的一个关系型数据库的用户角色的设计,由于我们要使用的MongoDB是一个文档型数据库,所以让我们重新审视一下这个结构。 这个数据结构的优点在于它避免了数据的冗余,每个表负责自己的数据,通过关联表进行关系的描述,同时也保证的数据的完整性:比如当你修改角色名称后,没有脏数据的产生。 但是这种事情在用户权限这个领域发生的频率到底有多少呢?有多少人每天不停的改的角色名称?当然如果你的业务场景确实是需要保证数据完整性,你还是应该使用关系型数据库。但如果没有高频的对于角色表的改动,其实我们是不需要这样的一个设计的。在MongoDB中我们可以将其简化为 ```json { _id: <id_generated> username: 'user', password: 'pass', roles: ['USER', 'ADMIN'] } ``` 基于以上考虑,我们重构一下 `User` 类, ```java @Data public class User { @Id private String id; @Indexed(unique=true, direction= IndexDirection.DESCENDING, dropDups=true) private String username; private String password; private String email; private Date lastPasswordResetDate; private List<String> roles; } ``` 当然你可能发现这个类有点怪,只有一些field,这个简化的能力是一个叫`lombok`类库提供的 ,这个很多开发过Android的童鞋应该熟悉,是用来简化POJO的创建的一个类库。简单说一下,采用 `lombok` 提供的 `@Data` 修饰符后可以简写成,原来的一坨getter和setter以及constructor等都不需要写了。类似的 `Todo` 可以改写成: ```java @Data public class Todo { @Id private String id; private String desc; private boolean completed; private User user; } ``` 增加这个类库只需在 `build.gradle` 中增加下面这行 ```gradle dependencies { // 省略其它依赖 compile("org.projectlombok:lombok:${lombokVersion}") } ``` ### 引入Spring Security 要在Spring Boot中引入Spring Security非常简单,修改 `build.gradle`,增加一个引用 `org.springframework.boot:spring-boot-starter-security`: ```gradle dependencies { compile("org.springframework.boot:spring-boot-starter-data-rest") compile("org.springframework.boot:spring-boot-starter-data-mongodb") compile("org.springframework.boot:spring-boot-starter-security") compile("io.jsonwebtoken:jjwt:${jjwtVersion}") compile("org.projectlombok:lombok:${lombokVersion}") testCompile("org.springframework.boot:spring-boot-starter-test") } ``` 你可能发现了,我们不只增加了对Spring Security的编译依赖,还增加 `jjwt` 的依赖。 Spring Security需要我们实现几个东西,第一个是UserDetails:这个接口中规定了用户的几个必须要有的方法,所以我们创建一个JwtUser类来实现这个接口。为什么不直接使用User类?因为这个UserDetails完全是为了安全服务的,它和我们的领域类可能有部分属性重叠,但很多的接口其实是安全定制的,所以最好新建一个类: ```java public class JwtUser implements UserDetails { private final String id; private final String username; private final String password; private final String email; private final Collection<? extends GrantedAuthority> authorities; private final Date lastPasswordResetDate; public JwtUser( String id, String username, String password, String email, Collection<? extends GrantedAuthority> authorities, Date lastPasswordResetDate) { this.id = id; this.username = username; this.password = password; this.email = email; this.authorities = authorities; this.lastPasswordResetDate = lastPasswordResetDate; } //返回分配给用户的角色列表 @Override public Collection<? extends GrantedAuthority> getAuthorities() { return authorities; } @JsonIgnore public String getId() { return id; } @JsonIgnore @Override public String getPassword() { return password; } @Override public String getUsername() { return username; } // 账户是否未过期 @JsonIgnore @Override public boolean isAccountNonExpired() { return true; } // 账户是否未锁定 @JsonIgnore @Override public boolean isAccountNonLocked() { return true; } // 密码是否未过期 @JsonIgnore @Override public boolean isCredentialsNonExpired() { return true; } // 账户是否激活 @JsonIgnore @Override public boolean isEnabled() { return true; } // 这个是自定义的,返回上次密码重置日期 @JsonIgnore public Date getLastPasswordResetDate() { return lastPasswordResetDate; } } ``` 这个接口中规定的很多方法我们都简单粗暴的设成直接返回某个值了,这是为了简单起见,你在实际开发环境中还是要根据具体业务调整。当然由于两个类还是有一定关系的,为了写起来简单,我们写一个工厂类来由领域对象创建 `JwtUser`,这个工厂就叫 `JwtUserFactory` 吧: ```java public final class JwtUserFactory { private JwtUserFactory() { } public static JwtUser create(User user) { return new JwtUser( user.getId(), user.getUsername(), user.getPassword(), user.getEmail(), mapToGrantedAuthorities(user.getRoles()), user.getLastPasswordResetDate() ); } private static List<GrantedAuthority> mapToGrantedAuthorities(List<String> authorities) { return authorities.stream() .map(SimpleGrantedAuthority::new) .collect(Collectors.toList()); } } ``` 第二个要实现的是 `UserDetailsService`,这个接口只定义了一个方法 `loadUserByUsername`,顾名思义,就是提供一种从用户名可以查到用户并返回的方法。注意,不一定是数据库哦,文本文件、xml文件等等都可能成为数据源,这也是为什么Spring提供这样一个接口的原因:保证你可以采用灵活的数据源。接下来我们建立一个 `JwtUserDetailsServiceImpl` 来实现这个接口。 ```java @Service public class JwtUserDetailsServiceImpl implements UserDetailsService { @Autowired private UserRepository userRepository; @Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { User user = userRepository.findByUsername(username); if (user == null) { throw new UsernameNotFoundException(String.format("No user found with username '%s'.", username)); } else { return JwtUserFactory.create(user); } } } ``` 为了让Spring可以知道我们想怎样控制安全性,我们还需要建立一个安全配置类 `WebSecurityConfig`: ```java @Configuration @EnableWebSecurity @EnableGlobalMethodSecurity(prePostEnabled = true) public class WebSecurityConfig extends WebSecurityConfigurerAdapter{ // Spring会自动寻找同样类型的具体类注入,这里就是JwtUserDetailsServiceImpl了 @Autowired private UserDetailsService userDetailsService; @Autowired public void configureAuthentication(AuthenticationManagerBuilder authenticationManagerBuilder) throws Exception { authenticationManagerBuilder // 设置UserDetailsService .userDetailsService(this.userDetailsService) // 使用BCrypt进行密码的hash .passwordEncoder(passwordEncoder()); } // 装载BCrypt密码编码器 @Bean public PasswordEncoder passwordEncoder() { return new BCryptPasswordEncoder(); } @Override protected void configure(HttpSecurity httpSecurity) throws Exception { httpSecurity // 由于使用的是JWT,我们这里不需要csrf .csrf().disable() // 基于token,所以不需要session .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and() .authorizeRequests() //.antMatchers(HttpMethod.OPTIONS, "/**").permitAll() // 允许对于网站静态资源的无授权访问 .antMatchers( HttpMethod.GET, "/", "/*.html", "/favicon.ico", "/**/*.html", "/**/*.css", "/**/*.js" ).permitAll() // 对于获取token的rest api要允许匿名访问 .antMatchers("/auth/**").permitAll() // 除上面外的所有请求全部需要鉴权认证 .anyRequest().authenticated(); // 禁用缓存 httpSecurity.headers().cacheControl(); } } ``` 接下来我们要规定一下哪些资源需要什么样的角色可以访问了,在 `UserController` 加一个修饰符 `@PreAuthorize("hasRole('ADMIN')")` 表示这个资源只能被拥有 `ADMIN` 角色的用户访问。 ```java /** * 在 @PreAuthorize 中我们可以利用内建的 SPEL 表达式:比如 'hasRole()' 来决定哪些用户有权访问。 * 需注意的一点是 hasRole 表达式认为每个角色名字前都有一个前缀 'ROLE_'。所以这里的 'ADMIN' 其实在 * 数据库中存储的是 'ROLE_ADMIN' 。这个 @PreAuthorize 可以修饰Controller也可修饰Controller中的方法。 **/ @RestController @RequestMapping("/users") @PreAuthorize("hasRole('ADMIN')") public class UserController { @Autowired private UserRepository repository; @RequestMapping(method = RequestMethod.GET) public List<User> getUsers() { return repository.findAll(); } // 略去其它部分 } ``` 类似的我们给 `TodoController` 加上 `@PreAuthorize("hasRole('USER')")`,标明这个资源只能被拥有 `USER` 角色的用户访问: ```java @RestController @RequestMapping("/todos") @PreAuthorize("hasRole('USER')") public class TodoController { // 略去 } ``` ### 使用application.yml配置SpringBoot应用 现在应该Spring Security可以工作了,但为了可以更清晰的看到工作日志,我们希望配置一下,在和 `src` 同级建立一个config文件夹,在这个文件夹下面新建一个 `application.yml`。 ```yml # Server configuration server: port: 8090 contextPath: # Spring configuration spring: jackson: serialization: INDENT_OUTPUT: true data.mongodb: host: localhost port: 27017 database: springboot # Logging configuration logging: level: org.springframework: data: DEBUG security: DEBUG ``` 我们除了配置了logging的一些东东外,也顺手设置了数据库和http服务的一些配置项,现在我们的服务器会在8090端口监听,而spring data和security的日志在debug模式下会输出到console。 现在启动服务后,访问 `http://localhost:8090` 你可以看到根目录还是正常显示的 ![根目录还是正常可以访问的][21] 但我们试一下 `http://localhost:8090/users` ,观察一下console,我们会看到如下的输出,告诉由于用户未鉴权,我们访问被拒绝了。 ``` 2017-03-10 15:51:53.351 DEBUG 57599 --- [nio-8090-exec-4] o.s.s.w.a.ExceptionTranslationFilter : Access is denied (user is anonymous); redirecting to authentication entry point org.springframework.security.access.AccessDeniedException: Access is denied at org.springframework.security.access.vote.AffirmativeBased.decide(AffirmativeBased.java:84) ~[spring-security-core-4.2.1.RELEASE.jar:4.2.1.RELEASE] ``` ## 集成JWT和Spring Security 到现在,我们还是让JWT和Spring Security各自为战,并没有集成起来。要想要JWT在Spring中工作,我们应该新建一个filter,并把它配置在 `WebSecurityConfig` 中。 ```java @Component public class JwtAuthenticationTokenFilter extends OncePerRequestFilter { @Autowired private UserDetailsService userDetailsService; @Autowired private JwtTokenUtil jwtTokenUtil; @Value("${jwt.header}") private String tokenHeader; @Value("${jwt.tokenHead}") private String tokenHead; @Override protected void doFilterInternal( HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException { String authHeader = request.getHeader(this.tokenHeader); if (authHeader != null && authHeader.startsWith(tokenHead)) { final String authToken = authHeader.substring(tokenHead.length()); // The part after "Bearer " String username = jwtTokenUtil.getUsernameFromToken(authToken); logger.info("checking authentication " + username); if (username != null && SecurityContextHolder.getContext().getAuthentication() == null) { UserDetails userDetails = this.userDetailsService.loadUserByUsername(username); if (jwtTokenUtil.validateToken(authToken, userDetails)) { UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken( userDetails, null, userDetails.getAuthorities()); authentication.setDetails(new WebAuthenticationDetailsSource().buildDetails( request)); logger.info("authenticated user " + username + ", setting security context"); SecurityContextHolder.getContext().setAuthentication(authentication); } } } chain.doFilter(request, response); } } ``` 事实上如果我们足够相信token中的数据,也就是我们足够相信签名token的secret的机制足够好,这种情况下,我们可以不用再查询数据库,而直接采用token中的数据。本例中,我们还是通过Spring Security的 `@UserDetailsService` 进行了数据查询,但简单验证的话,你可以采用直接验证token是否合法来避免昂贵的数据查询。 接下来,我们会在 `WebSecurityConfig` 中注入这个filter,并且配置到 `HttpSecurity` 中: ```java public class WebSecurityConfig extends WebSecurityConfigurerAdapter{ // 省略其它部分 @Bean public JwtAuthenticationTokenFilter authenticationTokenFilterBean() throws Exception { return new JwtAuthenticationTokenFilter(); } @Override protected void configure(HttpSecurity httpSecurity) throws Exception { // 省略之前写的规则部分,具体看前面的代码 // 添加JWT filter httpSecurity .addFilterBefore(authenticationTokenFilterBean(), UsernamePasswordAuthenticationFilter.class); } } ``` ### 完成鉴权(登录)、注册和更新token的功能 到现在,我们整个API其实已经在安全的保护下了,但我们遇到一个问题:所有的API都安全了,但我们还没有用户啊,所以所有API都没法访问。因此要提供一个注册、登录的API,这个API应该是可以匿名访问的。给它规划的路径呢,我们前面其实在`WebSecurityConfig`中已经给出了,就是 `/auth`。 首先需要一个AuthService,规定一下必选动作: ```java public interface AuthService { User register(User userToAdd); String login(String username, String password); String refresh(String oldToken); } ``` 然后,实现这些必选动作,其实非常简单: 1. 登录时要生成token,完成Spring Security认证,然后返回token给客户端 2. 注册时将用户密码用BCrypt加密,写入用户角色,由于是开放注册,所以写入角色系统控制,将其写成 `ROLE_USER` 3. 提供一个可以刷新token的接口 refresh 用于取得新的token ```java @Service public class AuthServiceImpl implements AuthService { private AuthenticationManager authenticationManager; private UserDetailsService userDetailsService; private JwtTokenUtil jwtTokenUtil; private UserRepository userRepository; @Value("${jwt.tokenHead}") private String tokenHead; @Autowired public AuthServiceImpl( AuthenticationManager authenticationManager, UserDetailsService userDetailsService, JwtTokenUtil jwtTokenUtil, UserRepository userRepository) { this.authenticationManager = authenticationManager; this.userDetailsService = userDetailsService; this.jwtTokenUtil = jwtTokenUtil; this.userRepository = userRepository; } @Override public User register(User userToAdd) { final String username = userToAdd.getUsername(); if(userRepository.findByUsername(username)!=null) { return null; } BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(); final String rawPassword = userToAdd.getPassword(); userToAdd.setPassword(encoder.encode(rawPassword)); userToAdd.setLastPasswordResetDate(new Date()); userToAdd.setRoles(asList("ROLE_USER")); return userRepository.insert(userToAdd); } @Override public String login(String username, String password) { UsernamePasswordAuthenticationToken upToken = new UsernamePasswordAuthenticationToken(username, password); final Authentication authentication = authenticationManager.authenticate(upToken); SecurityContextHolder.getContext().setAuthentication(authentication); final UserDetails userDetails = userDetailsService.loadUserByUsername(username); final String token = jwtTokenUtil.generateToken(userDetails); return token; } @Override public String refresh(String oldToken) { final String token = oldToken.substring(tokenHead.length()); String username = jwtTokenUtil.getUsernameFromToken(token); JwtUser user = (JwtUser) userDetailsService.loadUserByUsername(username); if (jwtTokenUtil.canTokenBeRefreshed(token, user.getLastPasswordResetDate())){ return jwtTokenUtil.refreshToken(token); } return null; } } ``` 然后建立AuthController就好,这个AuthController中我们在其中使用了表达式绑定,比如 `@Value("${jwt.header}")`中的 `jwt.header` 其实是定义在 `applicaiton.yml` 中的 ```yml # JWT jwt: header: Authorization secret: mySecret expiration: 604800 tokenHead: "Bearer " route: authentication: path: auth refresh: refresh register: "auth/register" ``` 同样的 `@RequestMapping(value = "${jwt.route.authentication.path}", method = RequestMethod.POST)` 中的 `jwt.route.authentication.path` 也是定义在上面的 ```java @RestController public class AuthController { @Value("${jwt.header}") private String tokenHeader; @Autowired private AuthService authService; @RequestMapping(value = "${jwt.route.authentication.path}", method = RequestMethod.POST) public ResponseEntity<?> createAuthenticationToken( @RequestBody JwtAuthenticationRequest authenticationRequest) throws AuthenticationException{ final String token = authService.login(authenticationRequest.getUsername(), authenticationRequest.getPassword()); // Return the token return ResponseEntity.ok(new JwtAuthenticationResponse(token)); } @RequestMapping(value = "${jwt.route.authentication.refresh}", method = RequestMethod.GET) public ResponseEntity<?> refreshAndGetAuthenticationToken( HttpServletRequest request) throws AuthenticationException{ String token = request.getHeader(tokenHeader); String refreshedToken = authService.refresh(token); if(refreshedToken == null) { return ResponseEntity.badRequest().body(null); } else { return ResponseEntity.ok(new JwtAuthenticationResponse(refreshedToken)); } } @RequestMapping(value = "${jwt.route.authentication.register}", method = RequestMethod.POST) public User register(@RequestBody User addedUser) throws AuthenticationException{ return authService.register(addedUser); } } ``` ## 验证时间 接下来,我们就可以看看我们的成果了,首先注册一个用户 `peng2`,很完美的注册成功了 ![注册用户][22] 然后在 `/auth` 中取得token,也很成功 ![取得token][23] 不使用token时,访问 `/users` 的结果,不出意料的失败,提示未授权。 ![不使用token访问users列表][24] 使用token时,访问 `/users` 的结果,虽然仍是失败,但这次提示访问被拒绝,意思就是虽然你已经得到了授权,但由于你的会员级别还只是普卡会员,所以你的请求被拒绝。 ![image_1bas22va52vk1rj445fhm87k72a.png-156.9kB][25] 接下来我们访问 `/users/?username=peng2`,竟然可以访问啊 ![访问自己的信息是允许的][26] 这是由于我们为这个方法定义的权限就是:拥有ADMIN角色或者是当前用户本身。Spring Security真是很方便,很强大。 ```java @PostAuthorize("returnObject.username == principal.username or hasRole('ROLE_ADMIN')") @RequestMapping(value = "/",method = RequestMethod.GET) public User getUserByUsername(@RequestParam(value="username") String username) { return repository.findByUsername(username); } ``` 本章代码: https://github.com/wpcfan/spring-boot-tut/tree/chap04 [1]: http://static.zybuluo.com/wpcfan/xx9vcwko6cnqlpcds9gkre83/image_1b783isnc14631jfr14groi5fuo1g.png [2]: http://static.zybuluo.com/wpcfan/de99jylqsulfydybajqnw6nc/image_1b7081mu6vke127v1ej2jhp1b1i9.png [3]: http://static.zybuluo.com/wpcfan/1k8jb3uyfab7f42cljyjitjj/image_1b7089410gi4u3o1r1pdt2t4om.png [4]: http://static.zybuluo.com/wpcfan/a8jzrxuyv7lz6cnigke3k1dp/image_1b778ebofol0d7ijcb1a5pamj13.png [5]: http://static.zybuluo.com/wpcfan/219ydnaga0jczzx76drzpd2o/image_1b77gr2om1rb7u8111du137e1hoe1t.png [6]: http://static.zybuluo.com/wpcfan/z0n134l61e9ofg64phcfjagj/image_1b77vqast1d2h1qioeepsdm1tkb9.png [7]: http://static.zybuluo.com/wpcfan/gd06q598sdaf1v848668hzvr/image_1b782evj1iuuupb2e71fr51ngm13.png [8]: http://static.zybuluo.com/wpcfan/aqezgb1pkk85651fpbyote7n/image_1b780non09ng12vr67ult7ml2m.png [9]: http://static.zybuluo.com/wpcfan/si7egzd0jh5369qe2ghzyn7y/image_1b77h6kies66199e1spn1vs0kin2a.png [10]: http://static.zybuluo.com/wpcfan/d7d20ngovrg3a9jzc441om19/image_1b77h90ud140r1ghc1p7qeq515542n.png [11]: http://static.zybuluo.com/wpcfan/xkapgi54m6944yzc5zkor2bf/image_1b77hol5adff1et81prknrn59s34.png [12]: http://static.zybuluo.com/wpcfan/nxmplqhi4732w6xy6160dtjk/image_1ba756i081dkm1jbgnm91q72fctc.png [13]: http://static.zybuluo.com/wpcfan/nxmplqhi4732w6xy6160dtjk/image_1ba756i081dkm1jbgnm91q72fctc.png [14]: https://tools.ietf.org/html/rfc7519 [15]: http://static.zybuluo.com/wpcfan/nxmplqhi4732w6xy6160dtjk/image_1ba756i081dkm1jbgnm91q72fctc.png [16]: http://static.zybuluo.com/wpcfan/nxmplqhi4732w6xy6160dtjk/image_1ba756i081dkm1jbgnm91q72fctc.png [17]: https://tools.ietf.org/html/rfc7519 [18]: http://static.zybuluo.com/wpcfan/999mi2nt99w5xujsqm2qoeeu/image_1bar35dmim9k197p4c81peitrr9.png [19]: https://en.wikipedia.org/wiki/Base64 [20]: http://www.iana.org/assignments/jwt/jwt.xhtml [21]: http://static.zybuluo.com/wpcfan/6w11oo6npfbj3cf4fni4jqge/image_1barkfcqf2cp8n21itv5gohiu9.png [22]: http://static.zybuluo.com/wpcfan/9giebd1gfzftneapg6rqnpk8/image_1bas1fb9l1v9i1ulo15p516qde8p13.png [23]: http://static.zybuluo.com/wpcfan/qbhtvp1w85v1kmr62jn8vtvs/image_1bas1km2p8961bfl36i7go10en1g.png [24]: http://static.zybuluo.com/wpcfan/kkfqqiepb23d7uuzqmoedfb3/image_1bas1oc621n6vaevd4l19vpkbk1t.png [25]: http://static.zybuluo.com/wpcfan/4teq3pgt6tb9klmac4a2c5i0/image_1bas22va52vk1rj445fhm87k72a.png [26]: http://static.zybuluo.com/wpcfan/sfq28srnylrdp7jio711goi7/image_1bas2gmmi1n0h13pkgqhehkj6t2n.png
1
naturalprogrammer/np-spring5-tutorial
Source code of Spring 5 tutorial by NaturalProgrammer.com
null
null
1
hadooparchitecturebook/clickstream-tutorial
Code for Tutorial on designing clickstream analytics application using Hadoop
null
# Clickstream Tutorial Code for Tutorial on designing clickstream analytics application using Hadoop We developed and tested this tutorial using Cloudera's Quickstart VM, CDH 5.2. You can download the VM here: http://www.cloudera.com/content/cloudera/en/documentation/DemoVMs/Cloudera-QuickStart-VM/cloudera_quickstart_vm.html Start the tutorial by using "git clone" to create a copy of this repository on your VM. ## To run the demo end-to-end: * Run setup.sh to create the directory structure needed for the tutorial (If you ran this tutorial before, you'll want to run cleanup.sh first) * Run 01_loggen/generate_apache_logs.sh - This will create an example clickstream log in /opt/weblogs * Follow the instructions in 02_ingestion/Flume/README.md - This will show you how to use Flume to ingest the logs we generated into Hadoop * Run 03_processing/01_dedup/pig/dedup.sh to remove duplicate events from the clickstream log * Follow the instructions in 03_processing/02_sessionization/mr/ to enrich the data with information about user sessions using MapReduce * Run 03_processing/03_paquetize/hive/run_all.sh to convert the sessionized data to Parquet format and to create the tables we'll later use for querying * Now you can run the query in 03_processing/04_query/query-parquet-log-table.hql using either Hive or Impala - this will give you the bounce-rate of your website for this day. * You can also run all the processing steps (dedup, sessionize and parquetize) automatically using an Oozie workflow. For that: * Run 04_orchestration/setup.sh to setup the Oozie library directory, and then upload the Hive and Pig scripts, the MapReduce jar and the Oozie workflow to HDFS. This is a requirement for running Oozie workflows. * Then run 04_orchestration/run.sh to trigger the workflow. Once the workflow is triggered, you can use Hue on the VM to watch the workflow dashboard and see its progress. When it finishes, you can query the data using Hive or Impala as mentioned above.
1
DhruvamSharma/Recycler-View-Series
This repository shares the code for the Recyclerview tutorials on Medium
null
# Recycler-View-Series This article is a part of the recyclerview series that I started and this repository will form the basis for the last 2 part left, ie, part 5 and part 6. Hope you all enjoyed this series and I was able to point a direction in the case of RecyclerView in Android. In this part I try to help with Item Decorations in RecyclerViews and how to master them. These parts like the others will be as easy to understand and implement. With visual help ofcourse! Happy reading :) ### The link to this project's tutorial: <a href="https://android.jlelse.eu/part-4-item-decorations-in-recyclerview-133cd8c218bb" target="_blank">Link to article</a> The link to the starting article is here: https://android.jlelse.eu/understanding-recyclerview-a-high-level-insight-part-1-dc3f81af5720 <img src = "https://github.com/DhruvamSharma/Recycler-View-Series/blob/master/docs/state4-1.jpeg" width = "200" height = "300"> <img src = "https://github.com/DhruvamSharma/Recycler-View-Series/blob/master/docs/state4-2.jpeg" width = "200" height = "300"> <img src = "https://github.com/DhruvamSharma/Recycler-View-Series/blob/master/docs/state4-3.jpeg" width = "200" height = "300">
0
arhohuttunen/spring-boot-test-examples
This is the repository containing examples for my Spring Boot testing tutorial.
junit5 spring-boot
# Spring Boot Test Examples ![Gradle Build](https://github.com/arhohuttunen/spring-boot-test-examples/workflows/Gradle%20Build/badge.svg) This is the repository containing examples for my [Spring Boot Testing Tutorial](https://www.arhohuttunen.com/spring-boot-testing-tutorial/).
0
diguage/byte-buddy-tutorial
“Byte Buddy Tutorial” 中文翻译:Byte Buddy 教程。
byte-buddy bytecode code-generation java jvm jvm-bytecode
null
0
jdubois/azure-native-spring-function
Tutorial on running Spring Boot + GraalVM native images on Azure Functions
azure azure-functions graal-native graalvm serverless spring-boot
# Running Spring Boot + GraalVM native images on Azure Functions This sample application shows how to: - Compile a Spring Boot application using GraalVM - Deploy and run that application on [Azure Functions](https://docs.microsoft.com/azure/azure-functions/?WT.mc_id=java-0000-judubois) This will use GitHub Actions to do all the heavy work: as we are creating a native image, it needs to be built on a Linux machine with GraalVM installed. ## Prerequisites - An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=java-0000-judubois). - The Azure CLI must be installed. [Install the Azure CLI](https://docs.microsoft.com/cli/azure/install-azure-cli/?WT.mc_id=java-0000-judubois). - Terraform must be installed. [Install Terraform](https://www.terraform.io/). To check if Azure is correctly set up, login using the CLI by running `az login`. ## Fork this repository All compilation and deployment will be done using GitHub Actions, so you need your own repository for this. The easiest way is to fork this repository to your own GitHub account, using the `fork` button on the top right-hand corner of this page. ## Create the cloud infrastructure using Terraform You need to configure the following environment variables: ```bash export TF_VAR_AZ_LOCATION=westeurope export TF_VAR_AZ_RESOURCE_GROUP=azure-native-spring-function export TF_VAR_AZ_FUNCTION_NAME_APP=<your-unique-name> export TF_VAR_AZ_STORAGE_NAME=<your-unique-name> ``` - `TF_VAR_AZ_LOCATION` : The name of the Azure location to use. Use `az account list-locations` to list available locations. Common values are `eastus`, `westus`, `westeurope`. - `TF_VAR_AZ_RESOURCE_GROUP` : The resource group in which you will work. It should be unique in your subscription, so you can probably keep the default `azure-native-spring-function`. - `TF_VAR_AZ_FUNCTION_NAME_APP` : Functions will run into an application, and its name should be unique across Azure. It must contain only alphanumeric characters and dashes and up to 60 characters in length. - `TF_VAR_AZ_STORAGE_NAME` : Functions binaries and configuration will be stored inside a storage account. Its name should also be unique across Azure. It must be between 3 and 24 characters in length and may contain numbers and lowercase letters only. In order not to type those values again, you can store them in a `.env` file at the root of this project: - This `.env` file will be ignored by Git (so it will remain on your local machine and won't be shared). - You will be able to configure those environment variables by running `source .env`. Go to the `terraform` directory and run: - `terraform init` to initialize your Terraform environment - `terraform apply --auto-approve` to create all the necessary Azure resources This will create the following Azure resources: - A resource group that will store all resources (just delete this resource group to remove everything) - An Azure Functions plan. This is a consumption plan, running on Linux: you will only be billed for your usage, with a generous free tier. [Here is the full pricing documentation](https://azure.microsoft.com/pricing/details/functions/?WT.mc_id=java-0000-judubois). - An Azure Functions application, that will use the plan described in the point above. - An Azure Storage account, which will be used to store your function's data (the binary and the configuration files). ## Configure GitHub Actions to build and deploy the application The GitHub Actions workflow that we will use is available in [.github/workflows/build-and-deploy.yml](.github/workflows/build-and-deploy.yml). This GitHub Action will need to use some variables, for this go to your project fork and select "Settings", then "Secrets". ### Configure the AZ_FUNCTION_NAME_APP secret The `AZ_FUNCTION_NAME_APP` is the name of your function application. It is the same as the `TF_VAR_AZ_FUNCTION_NAME_APP` environment variable that we configured earlier with Terraform. Create a new secret called `AZ_FUNCTION_NAME_APP`, paste the value in it, and click "Add secret". ### Configure the AZURE_CREDENTIALS secret The `AZURE_CREDENTIALS` will allow the GitHub Actions workflow to log in your Azure account, and deploy the application. This is a JSON payload that we will get by executing the following command: ```bash RESOURCE_ID=$(az group show --name $TF_VAR_AZ_RESOURCE_GROUP --query id -o tsv) SPNAME="sp-$(az functionapp list --resource-group $TF_VAR_AZ_RESOURCE_GROUP --query '[].name' -o tsv)" az ad sp create-for-rbac --name "${SPNAME}" --role contributor --scopes "$RESOURCE_ID" --sdk-auth ``` Create a new secret called `AZURE_CREDENTIALS`, paste the JSON payload in it, and click "Add secret". ## Deploy and test Now that everything is set up, your application will be automatically built as a GraalVM native image, and deployed to Azure Functions. You can change some code, or force a commit to trigger such a build: ```bash git commit -m "force build" --allow-empty && git push ``` You will be able to monitor that process in the "Actions" tab of your fork of the project. Once the function is deployed, you can access it though the [Azure Portal](https://portal.azure.com/?WT.mc_id=java-0000-judubois). You will there be able to monitor it and test it. - Select your resource group - Select the Azure Functions application you created (its type is "App Service") - In "Functions", find the function that you have just deployed - Select "Code + Test" - You can click on "Test/Run": select a "POST" method, and enter `Azure` as body. You should have the following output: `{"message": "Hello, Azure!\n"}` As you will want to test the performance of this function, still on the "Code + Test" screen, select "Get function URL". Use that function URL to test the performance of your function: ```bash time curl <YOUR-FUNCTION-URL> -d 'Azure' -H "Content-Type: application/json" ``` For monitoring your function, you can also select the "Monitor" tab and create an Azure Applications Insight instance, which will be able to give you detailed metrics (like RAM usage) of your function. ## Tuning the function The function configuration is in `src/main/function`: - The name of the directory should be the same as the name of the function. That's how Azure Functions can apply the configuration. - Documentation for the `host.json` and `function.json` files can be found at [Azure Functions custom handlers](https://docs.microsoft.com/azure/azure-functions/functions-custom-handlers/?WT.mc_id=java-0000-judubois). The application used here is very simple, and comes from [https://github.com/spring-projects-experimental/spring-graalvm-native/tree/master/spring-graalvm-native-samples/function-netty](https://github.com/spring-projects-experimental/spring-graalvm-native/tree/master/spring-graalvm-native-samples/function-netty). If you want to work on this function or run it locally, the [https://github.com/spring-projects-experimental/spring-graalvm-native](https://github.com/spring-projects-experimental/spring-graalvm-native) project gives all the necessary documentation.
1
bleeding182/samples
Code samples and tutorials
null
# samples Code samples and tutorials
0
thymeleaf/thymeleafexamples-gtvg
Good Thymes Virtual Grocery - Companion application for the Using Thymeleaf" tutorial downloadable at the Thymeleaf website: http://www.thymeleaf.org/documentation.html"
null
null
1
AutomateThePlanet/LambdaTest-Selenium4-Java-Tutorial
Contains Code from the LambdaTest Selenium 4 Java Tutorial
null
# LambdaTest-Selenium4-Java-Tutorial Contains Code from the LambdaTest Selenium 4 Java Tutorial
1
afd/JavaTutorialQuestions
Tutorial Questions for the Programming II course at Imperial College London
null
# Java Programming: Ally's Tutorial Questions The best way to learn a programming language and the concepts that underlie the language's design is to do *lots* of programming. The aim of these tutorial questions is to give you the opportunity to write, inspect, debug and play with a bunch of reasonably small programs. There are quite a lot of questions, they form part of the examinable material for the course, and thus I strongly encourage you to attempt *all* of them. I also encourage you to explore your own variations of and extensions to the tutorial questions. Think of extra features you could add to some of the programs, and try to add them. ## When are these tutorials? There aren't any. I'm calling them "tutorial questions", but really the questions are for your own self-study. I won't be running tutorial sessions during my part of the course; instead we will do lots of live coding in class. While I might touch on a few of these questions, the vast majority of them won't be discussed. Similarly, your programming tutor or undergraduate teaching assistant might choose to go over some of these questions during PPT sessions, but they are not part of the core material to be covered in PPT groups. So, once again: do try out all the questions **in your own time** before the final test! ## When should I attempt each question? The questions are presented in a reasonably logical order, but this order might not match exactly the order we cover material during the lectures. I suggest that you try out each question as soon as you feel you've learned enough to have a stab at it. I've indicated using links where there are dependencies between questions, and have tagged each question with one or more topic areas. ## Reporting errors For everyone's benefit (including the benefit of future students), please email me ([afd](mailto:afd@ic.ac.uk)) if you find errors in these sheets or the sample solutions. ## If you get stuck * Ask me for help after lectures and tutorials * Attend the lab sessions and ask the lab helpers for advice * Send me an email ([afd](mailto:afd@ic.ac.uk)) However, before you ask for help do make sure you have spent a significant amount of time scratching your head and thinking about your problem, and looking for solutions in the lecture notes and other available sources. You will likely learn a lot by really trying to figure things out for yourself. If you are still stuck after this then I, and the others involved in the course, will be very happy to help. ## Question labels, dependencies and tags Each question is labelled with a 4-digit hex identifier, e.g. 98e3. Some of the questions depend on other questions; I have indicated wherever this is the case, linking to the prerequisite question. To help you decide how you should prioritise working through the questions, I have attached one or more tags to each question in the list below. The tags are as follows: * Recap: focuses on recapping basic imperative concepts of Java: loops, recursion, variables, arrays and enumerations. * SimpleObjects: covers basic use of objects (with little or no use of interfaces, inheritance, etc.). * Interfaces: covers concepts relating to Java interfaces. * Functional: focuses on functional programming features of Java: streams, lambdas and method references. * Inheritance: covers the design and implementation of subclasses. * AbstractClasses: focuses on using abstract superclasses to share common state and methods among subclasses. * Generics: focuses on building generic containers, and on technical aspects of Java generics. * Exceptions: covers handling unexpected program behaviours using Java's exception mechanisms. * MemoryManagement: explores the stack, heap and garbage collector. * Advanced: Challenging questions that bring together many concepts covered during my part of the course. If you can solve these questions using only the hints provided then you are doing *very* well! You might prefer to work through these questions referring to the sample solutions along the way. ## The questions! You can access the questions via the table below. Solutions are provided for all questions, and code solutions for all questions are available at ```solutions/code```. It is totally up to you when to look at these. I suggest you attempt each question without reference to its solution, and start to peek at the solutions when you get stuck, or when you believe you have made good progress on a question. Much of Object Oriented Programming is not an exact science: there is a lot of room for creativity, and when designing an application one often has to make a choice between multiple imperfect approaches, each with different pros and cons. As a result, you will likely find that some of your answers differ from the sample solutions. When this is the case, think hard about whether the sample solution is better than your solution, whether your solution is better than the sample solution, or whether they are both viable alternatives. I'm very happy to discuss alternative solutions. Also, please get in touch if there are parts of the solutions that you do not understand, of if you spot errors. | Label | Name | Topic tag(s) | Depends on | Solution | |---------------------------|-----------------------------------|-------------------------|-------------|----------| | [98e3](questions/98e3.md) | *... 1 4 2 1 4 2 1 ...* | Recap | | [Solution](solutions/98e3.md) | | [f79b](questions/f79b.md) | *Perfect palindromic cubes* | Recap | | [Solution](solutions/f79b.md) | | [4c70](questions/4c70.md) | *Lottery numbers* | Recap | | [Solution](solutions/4c70.md) | | [014e](questions/014e.md) | *Random numbers* | Recap | | [Solution](solutions/014e.md) | | [2d33](questions/2d33.md) | *Reversed order of input* | Recap | | [Solution](solutions/2d33.md) | | [f7c3](questions/f7c3.md) | *Pig Latin* | Recap | | [Solution](solutions/f7c3.md) | | [67dd](questions/67dd.md) | *Word count* | Recap | | [Solution](solutions/67dd.md) | | [7ec8](questions/7ec8.md) | *Battling fighters* | Recap, SimpleObjects | | [Solution](solutions/7ec8.md) | | [8d24](questions/8d24.md) | *Lucky battling fighters* | Recap, SimpleObjects | [7ec8](questions/7ec8.md) | [Solution](solutions/8d24.md) | | [bec2](questions/bec2.md) | *Music collection* | Recap, SimpleObjects | | [Solution](solutions/bec2.md) | | [c2b8](questions/c2b8.md) | *Irresponsible rectangle* | SimpleObjects | | [Solution](solutions/c2b8.md) | | [d363](questions/d363.md) | *Bloated person* | SimpleObjects | | [Solution](solutions/d363.md) | | [7206](questions/7206.md) | *Understanding references* | SimpleObjects | | [Solution](solutions/7206.md) | | [937d](questions/937d.md) | *Flawed rectangle* | SimpleObjects | | [Solution](solutions/937d.md) | | [bdb4](questions/bdb4.md) | *Flawed house* | SimpleObjects | | [Solution](solutions/bdb4.md) | | [0378](questions/0378.md) | *Comparing people* | Interfaces | | [Solution](solutions/0378.md) | | [6346](questions/6346.md) | *Depth of arithmetic expressions* | Interfaces | | [Solution](solutions/6346.md) | | [e6fd](questions/e6fd.md) | *Bit sets* | Interfaces | | [Solution](solutions/e6fd.md) | | [fe94](questions/fe94.md) | *Using Stream.map and Stream.filter* | Functional | | [Solution](solutions/fe94.md) | | [68e6](questions/68e6.md) | *Using Stream.reduce* | Functional | | [Solution](solutions/68e6.md) | | [0f05](questions/0f05.md) | *Coloured points* | Inheritance | | [Solution](solutions/0f05.md) | | [dd4c](questions/dd4c.md) | *Clocks* | Inheritance | | [Solution](solutions/dd4c.md) | | [8f65](questions/8f65.md) | *Lucky battling fighters with inheritance* | Inheritance | [8d24](questions/8d24.md) | [Solution](solutions/8f65.md) | | [845d](questions/845d.md) | *Books and dictionaries* | Inheritance | | [Solution](solutions/845d.md) | | [e93f](questions/e93f.md) | *Apparent and actual types* | Inheritance | | [Solution](solutions/e93f.md) | | [d3f5](questions/d3f5.md) | *Streams and downcasting* | Functional, Inheritance, Generics | | [Solution](solutions/d3f5.md) | | [5235](questions/5235.md) | *Equality between points* | ObjectEquality | [0f05](questions/0f05.md) | [Solution](solutions/5235.md) | | [710c](questions/710c.md) | *The consequences of overriding `equals`* | ObjectEquality | [5235](questions/5235.md) | [Solution](solutions/710c.md) | | [aa68](questions/aa68.md) | *Symmetric equality testing* | ObjectEqualilty | [5235](questions/5235.md) | [Solution](solutions/aa68.md) | | [0c21](questions/0c21.md) | *Properties* | AbstractClasses | | [Solution](solutions/0c21.md) | | [236b](questions/236b.md) | *Fields for properties* | AbstractClasses | [0c21](questions/0c21.md) | [Solution](solutions/236b.md) | | [5981](questions/5981.md) | *Shapes* | AbstractClasses | | [Solution](solutions/5981.md) | | [dc38](questions/dc38.md) | *Email management system* | AbstractClasses | | [Solution](solutions/dc38.md) | | [1486](questions/1486.md) | *String stack* | Interfaces | | [Solution](solutions/1486.md) | | [8a61](questions/8a61.md) | *Int set* | Interfaces | [1486](questions/1486.md) | [Solution](solutions/8a61.md) | | [85bb](questions/85bb.md) | *String stack iterators* | AbstractClasses, Interfaces | [1486](questions/1486.md) | [Solution](solutions/85bb.md) | | [a6e7](questions/a6e7.md) | *Int set iterators* | AbstractClasses, Interfaces | [8a61](questions/8a61.md) [85bb](questions/85bb.md) | [Solution](solutions/a6e7.md) | | [2ffc](questions/2ffc.md) | *Generic stacks* | Generics | [1486](questions/1486.md) | [Solution](solutions/2ffc.md) | | [b401](questions/b401.md) | *Generic sets* | Generics | [8a61](questions/8a61.md) | [Solution](solutions/b401.md) | | [336b](questions/336b.md) | *Evolving the Set interface* | Interfaces, Advanced | [b401](questions/b401.md) | [Solution](solutions/336b.md) | | [17b1](questions/17b1.md) | *Default methods* | Interfaces, Advanced | | [Solution](solutions/17b1.md) | | [96df](questions/96df.md) | *Tree nodes* | Generics | | [Solution](solutions/96df.md) | | [7041](questions/7041.md) | *Cloning tree nodes* | Generics | [96df](questions/96df.md) | [Solution](solutions/7041.md) | | [888a](questions/888a.md) | *Generic methods with streams* | Generics, Functional | [68e6](questions/68e6.md) | [Solution](solutions/888a.md) | | [11e2](questions/11e2.md) | *Bounded generic methods with streams* | Generics, Functional | | [Solution](solutions/11e2.md) | | [c822](questions/c822.md) | *Problems cloning tree nodes* | Advanced | [7041](questions/7041.md) | [Solution](solutions/c822.md) | | [735a](questions/735a.md) | *Generic iterators* | Generics | [85bb](questions/85bb.md) [a6e7](questions/a6e7.md) [b401](questions/b401.md) | [Solution](solutions/735a.md) | | [876b](questions/876b.md) | *Generics and subclasses* | Generics, Inheritance | | [Solution](solutions/876b.md) | | [1aeb](questions/1aeb.md) | *Generic number manipulation* | Generics | | [Solution](solutions/1aeb.md) | | [b4a5](questions/b4a5.md) | *Observing the garbage collector* | MemoryManagement | | [Solution](solutions/b4a5.md) | | [1ae9](questions/1ae9.md) | *Reusing immutable value objects* | MemoryManagement | [0f05](questions/0f05.md) | [Solution](solutions/1ae9.md) | | [290b](questions/290b.md) | *Memory leaks in Java* | MemoryManagement, Advanced | | [Solution](solutions/290b.md) | | [5566](questions/5566.md) | *Exception-throwing stacks* | Exceptions | [1486](1486.md) | [Solution](solutions/5566.md) | | [a22c](questions/a22c.md) | *No duplicate email addresses* | Exceptions | [dc38](questions/dc38.md) | [Solution](solutions/a22c.md) | | [e093](questions/e093.md) | *Average of numbers* | Exceptions | | [Solution](solutions/e093.md) | | [7e2a](questions/7e2a.md) | *Stack overflow* | Exceptions | | [Solution](solutions/7e2a.md) | | [30cd](questions/30cd.md) | *Heap exhaustion* | Exceptions | | [Solution](solutions/30cd.md) | | [74d2](questions/74d2.md) | *Exceptions and inheritance (i)* | Exceptions, Inheritance | | [Solution](solutions/74d2.md) | | [2862](questions/2862.md) | *Exceptions and inheritance (ii)* | Exceptions, Inheritance | | [Solution](solutions/2862.md) | | [153d](questions/153d.md) | *Exceptions and inheritance (iii)* | Exceptions, Inheritance | | [Solution](solutions/153d.md) | | [5d30](questions/5d30.md) | *Unreliable buffered reader* | Exceptions | | [Solution](solutions/5d30.md) | | [1171](questions/1171.md) | *Cloning graphs* | Advanced | | [Solution](solutions/1171.md) | | [f763](questions/f763.md) | *Simulating garbage collection* | Advanced | | [Solution](solutions/f763.md) | | [9a9b](questions/9a9b.md) | *Transposing tunes* | Advanced | | [Solution](solutions/9a9b.md) | | [b33f](questions/b33f.md) | *Logging using a functional interface* | Advanced | [888a](questions/888a.md) | [Solution](solutions/b33f.md) | ## More hex strings When I am gone, if someone wants to add more questions then please consume the remaining [hex strings here](questions/hex_strings.md).
1
jamesaoverton/obo-tutorial
A tutorial on using Open Biological and Biomedical Ontologies (OBO)
null
# OBO Tutorial The [Open Biological and Biomedical Ontologies (OBO)](http://obofoundry.org) provide a suite of high-quality, interoperable, free and open source tools for sharing scientific knowledge and making new discoveries. This tutorial reflects the lessons that I've learned using OBO ontologies to work with scientific data. You'll learn how to use OBO ontologies to communicate more clearly, to integrate data, and to improve search and analysis. We use a single running example to keep things concrete: a spreadsheet of data about histology observations. Starting with this data, we build an application ontology, transform the data into [linked data](http://www.w3.org/standards/semanticweb/data), and then apply an automated reasoner and query over it. All using open source code and tools. [**Get Started!**](https://github.com/jamesaoverton/obo-tutorial/blob/master/docs/introduction.md) 1. [Introduction](https://github.com/jamesaoverton/obo-tutorial/blob/master/docs/introduction.md) 2. [Names and Naming](https://github.com/jamesaoverton/obo-tutorial/blob/master/docs/names.md) 3. [Open Biological and Biomedical Ontologies (OBO)](https://github.com/jamesaoverton/obo-tutorial/blob/master/docs/obo.md) 4. [Using and Reusing Ontologies](https://github.com/jamesaoverton/obo-tutorial/blob/master/docs/using-and-reusing.md) 5. [Processing Data with Ontologies](https://github.com/jamesaoverton/obo-tutorial/blob/master/docs/processing-data.md) 6. [Updating, Testing, and Releasing Ontologies](https://github.com/jamesaoverton/obo-tutorial/blob/master/docs/ontology-development.md) [**Download PDF and code**](https://github.com/jamesaoverton/obo-tutorial/releases/latest) NOTE: This is still a work in progress. Not all of the sections are complete. ## Other Resources Here are some links to other resources for learning about OBO: - [GO Editors Guide](http://go-ontology.readthedocs.io) ## Requirements To read through the tutorial and look at most of the files, all you need is a web browser. To view the OWL files you should use the desktop version of [Protégé](http://protege.stanford.edu). If you want to dig deeper, see [code/README.md](https://github.com/jamesaoverton/obo-tutorial/blob/master/code/README.md). ## Files Here's a quick overview of the repository: - `docs`: the tutorial content in [Markdown format](https://help.github.com/articles/github-flavored-markdown) - `examples`: data and code files referred to in the tutorial - `images`: supporting images - `code`: more elaborate code examples to support the tutorial - `bin`: other code for working with the tutorial ## Contributing Corrections, improvements, suggestions, bug reports, etc. are all very much appreciated! Please: - [add an issue to our tracker](https://github.com/jamesaoverton/obo-tutorial/issues) - [create a pull request](https://github.com/jamesaoverton/obo-tutorial/pulls) - or email me at [james@overton.ca](mailto:james@overton.ca) ## License Copyright © 2017, James A. Overton Distributed under the CC-by 3.0 License: <https://creativecommons.org/licenses/by/3.0/>
1
traex/SlidingMenuExample
Example for one of my tutorials at http://blog.robinchutaux.com/blog/how-to-create-a-menu-like-hello-sms/
null
SlidingMenuExample ================== ![SlidingMenuExample](https://github.com/traex/SlidingMenuExample/blob/master/header.png) This is an example of [How to create a menu like Hello SMS](http://blog.robinchutaux.com/blog/how-to-create-a-menu-like-hello-sms/) [HelloSMS](https://hellotext.com) is an awesome app with a design concept that I like very much ! So I wanted to know how to create the same menu and after some digging I found a way to do it. It was a little bit difficult so I explained [here](http://blog.robinchutaux.com/blog/how-to-create-a-menu-like-hello-sms/) how to achieve the same menu with interaction.
1
sbrosinski/spring-boot-on-k8s
Tutorial: Deploying a Spring Boot app on Kubernetes
null
# Tutorial: Deploying a Spring Boot app on Kubernetes I set up this project to demonstrate how to dockerize a Spring Boot app and deploy, configure and scale it on Kubernetes. In this tutorial I'm using [minikube](https://github.com/kubernetes/minikube) locally, you can also read my last post on [how to run Kubernetes on AWS](https://brosinski.com/post/kubernetes-on-aws-with-kops/) or try hosted Kubernetes in [Google Container Engine](https://cloud.google.com/container-engine/). ## Prequisites To follow along, [check out this repo](https://github.com/sbrosinski/spring-boot-on-k8s) and make sure you have the following tools ready: * [docker](https://www.docker.com/products/docker#/) - to build the docker images we want to deploy * [minikube](https://github.com/kubernetes/minikube) - a local Kubernetes environment * [kubectl](http://kubernetes.io/docs/user-guide/prereqs/) - the Kubernetes command line interface, on macOS you can `brew install kubernetes-cli` it ## The Spring Boot Service The details of this service don't matter much. I used the [Spring Initializr](http://start.spring.io/) to create a very simple Spring Boot app which answers on port 8090 to these routes: * `/hello` - which returns {"greeting": "hello world"} * `/health` - to report the app's health status The app can be built with `gradle clean build` which results in a standalone jar named `demo-service-0.0.1-SNAPSHOT.jar` in `build/libs`. The simplest way to run the app is with `java -jar build/libs/demo-service-0.0.1-SNAPSHOT.jar`. ## Creating a Docker image We need a container which has a JDK. If you just create an Ubuntu image with the standard Oracle JDK installation, you will end up with and image size of about 1 GB. Not nice to work with. There are better options though: [Creating a minimial JDK installation based on an AlpineLinux image](https://developer.atlassian.com/blog/2015/08/minimal-java-docker-containers/). The `docker/minimal-java` directory contains a Dockerfile I generated taking that approach. So we'll just create our own JDK base image first: cd docker/minimal-java docker build -t sbrosinski/minimal-java . Now we create a container for our demo service inherating from that base image: cd docker/demo-service docker build -t sbrosinski/demo-service . This Dockerfile is very simple and based on [Spring Boot's docker intro](https://spring.io/guides/gs/spring-boot-docker/): FROM sbrosinski/minimal-java VOLUME /tmp EXPOSE 8090 ADD demo-service-0.0.1-SNAPSHOT.jar app.jar RUN sh -c 'touch /app.jar' ENV JAVA_OPTS="" ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar" ] If you do this in production [you should probably add some memory limiting options](http://matthewkwilliams.com/index.php/2016/03/17/docker-cgroups-memory-constraints-and-java-cautionary-tale/) to the java call. ## Running the Docker image To try it out, we can run it locally just using docker: docker run -p 8090:8090 -t --name demo-service --rm b7i/demo-service:latest curl http://localhost:8090/hello => {"greeting":"hello world"} docker stop demo-service ## Publishing the Docker image Kubernetes will have to pull the docker image from a registry. For this example we can use a public repository on DockerHub. Register on [docker.com](http://docker.com) to create a docker ID. You can now log into your DockerHub account from your machine with: docker login Push your image to DockerHub with: docker push sbrosinski/demo-service The image for the demo service is publicly available at [https://hub.docker.com/r/sbrosinski/demo-service/](https://hub.docker.com/r/sbrosinski/demo-service/). ## Setting up Kubernetes We're using the local Kubernetes cluster provided by minikube. Start your cluster with: minikube start You can take a look at the (still empty) Kubernetes dashboard with: minikube dashboard ## Deploying the service to Kubernetes To run our application on the minikube cluster we need to specify a deployment. The deployment descriptor looks like this: apiVersion: extensions/v1beta1 kind: Deployment metadata: name: demo-service-deployment spec: replicas: 2 # tells deployment to run 2 pods matching the template template: # create pods using pod definition in this template metadata: labels: app: demo-service spec: containers: - name: demo-service image: sbrosinski/demo-service ports: - containerPort: 8090 Create this deployment on the cluster using kubectl: kubectl create -f deployment.yml You can look at the deployment with: kubectl describe deployment demo-service-deployment Name: demo-service-deployment Namespace: default CreationTimestamp: Fri, 18 Nov 2016 11:42:05 +0100 Labels: app=demo-service Selector: app=demo-service Replicas: 2 updated | 2 total | 2 available | 0 unavailable StrategyType: RollingUpdate MinReadySeconds: 0 RollingUpdateStrategy: 1 max unavailable, 1 max surge OldReplicaSets: <none> NewReplicaSet: demo-service-deployment-1946011246 (2/2 replicas created) Events: FirstSeen LastSeen Count From SubobjectPath Type Reason Message --------- -------- ----- ---- ------------- -------- ------ ------- 1m 1m 1 {deployment-controller } Normal ScalingReplicaSet Scaled up replica set demo-service-deployment-1946011246 to 2 Two pods have been created, a replica set, and the default rolling update strategy. You can also look at the pods with: kubectl get pods NAME READY STATUS RESTARTS AGE demo-service-deployment-1946011246-ap47n 1/1 Running 0 3m demo-service-deployment-1946011246-u3dcj 1/1 Running 0 3m We can join these pods as part of a service and expose it outside of our cluster. Create a service with: kubectl create -f service.yml The service descriptor looks like this: apiVersion: v1 kind: Service metadata: name: demo-service spec: ports: - port: 8090 targetPort: 8090 selector: app: demo-service type: NodePort By specifying a service type of `NodePort` we declare to expose the service outside the cluster. Type `LoadBalance`would create a load balancer (e.g. ELB on AWS, but this feature is not availabe for minikube), type `ClusterIP` would expose the service only within the cluster. We can look at the service details with: kubectl describe service demo-service Name: demo-service Namespace: default Labels: <none> Selector: app=demo-service Type: NodePort IP: 10.0.0.221 Port: <unset> 8090/TCP NodePort: <unset> 31039/TCP Endpoints: 172.17.0.6:8090,172.17.0.7:8090 Session Affinity: None No events. To now access the service, we can use a minikube command to tell us the exact service address: minikube service demo-service This would open your browser and point it, for example, to `http://192.168.99.100:31039`. Port 31039 is the NodePort we requested and the IP address is the address of our minikube cluster. We can now access the service routes: curl http://192.168.99.100:31039/hello => {"greeting":"hello world"} That's it for now. To expand on this you can try the following: Make the service use a DB and play with Kubernetes persistent volumes and service discovery.
0
caveofprogramming/spring-framework-course
Source code for the Cave of Programming Spring Framework tutorial
java spring springframework springmvc
Source code for Cave of Programming Spring Course (Spring version 3.2)
1
halide/CVPR2015
Example code used in the CVPR 2015 tutorial
null
To get started, download a binary release of Halide from halide-lang.org and untar/unzip it into this directory.
1
sivvig/ZombieBird
Zombie Bird source code (http://www.kilobolt.com/zombie-bird-tutorial-flappy-bird-remake.html)
null
# ZombieBird LibGDX Zombie Bird Tutorial Final Output with code based on Day 12 off Zombie Bird Updated configuration of gradle and dependent libraries to work with later versions of Android Studio ![Zombie Bird Image](http://i.imgur.com/F36XNxj.png)
0
Alchyr/BasicMod
A basic, empty Slay the Spire mod + tutorial.
null
# Basic Mod This is an empty Slay the Spire mod + a modding tutorial. This tutorial will help with setup and the basics of Slay the Spire modding, but it will not teach you Java. If you know nothing of Java or programming in general, you are strongly recommended to look up a free online course and do at least some of it. It is possible to do modding with almost no proper knowledge, but it will make things much more difficult. --- ## Check the wiki to get started: https://github.com/Alchyr/BasicMod/wiki --- ## Know what you're doing? You can still use this mod as a base, or you could use another template like https://github.com/DarkVexon/ProTemplate You can find more options in the pins of the #modding-technical channel in the Slay the Spire discord server. --- ### Some HD Slay the Spire art assets (courtesy of Gremious, creator of DefaultMod): Includes: - Empty Relic Template feat. empty bottle - Empty Card Template - Color-Changable cardback - A couple of HD Monster vectors (Louse, Nob, Sentry, Sneaky Gremlin) - A coupe of HD items (J.A.X., A Coin) - 2 people silhouettes - A curse Background https://github.com/Gremious/StS-DefaultModBase#some-hd-slay-the-spire-art-assets ---
0
SomMeri/antlr-step-by-step
Example project for ANTLR tutorial blog post.
null
null
1
codesandnotes/restsecurity
A small tutorial project on how to implement REST security features
null
restsecurity ============ A small tutorial project on how to implement REST security features. Check the tutorial's related posts on http://www.codesandnotes.be/2014/10/31/restful-authentication-using-spring-security-on-spring-boot-and-jquery-as-a-web-client/ and http://www.codesandnotes.be/2015/02/05/spring-securitys-csrf-protection-for-rest-services-the-client-side-and-the-server-side/ Enjoy!
1
corda/cordapp-template-java
A Java CorDapp Template. Extend it via the Hello, World tutorial: https://docs.corda.net/hello-world-introduction.html
null
# cordapp-template-java (Corda v5.2) ## This template repository provides: - A pre-setup Cordapp Project which you can use as a starting point to develop your own prototypes. - A base Gradle configuration which brings in the dependencies you need to write and test a Corda 5 Cordapp. - A set of Gradle helper tasks, provided by the [Corda runtime gradle plugin](https://github.com/corda/corda-runtime-os/tree/release/os/5.2/tools/corda-runtime-gradle-plugin#readme), which speed up and simplify the development and deployment process. - Debug configuration for debugging a local Corda cluster. - The MyFirstFlow code which forms the basis of this getting started documentation, this is located in package com.r3.developers.cordapptemplate.flowexample - A UTXO example in package com.r3.developers.cordapptemplate.utxoexample packages - Ability to configure the Members of the Local Corda Network. To find out how to use the template, please refer to the *CorDapp Template* subsection within the *Developing Applications* section in the latest Corda 5 documentation at https://docs.r3.com/ ## Prerequisite 1. Java 17 2. Corda-cli (v5.2), Download [here](https://github.com/corda/corda-runtime-os/releases/tag/release-5.2.0.0). You need to install Java 17 first. 3. Docker Desktop ## Setting up 1. We will begin our test deployment with clicking the `startCorda`. This task will load up the combined Corda workers in docker. A successful deployment will allow you to open the REST APIs at: https://localhost:8888/api/v5_2/swagger#. You can test out some of the functions to check connectivity. (GET /cpi function call should return an empty list as for now.) 2. We will now deploy the cordapp with a click of `vNodeSetup` task. Upon successful deployment of the CPI, the GET /cpi function call should now return the meta data of the cpi you just upload ## Flow Management Tool[Optional] We had developed a simple GUI for you to interact with the cordapp. You can access the website by using https://localhost:5000 or https://127.0.0.1:5000. The Flow Management Tool will automatically connect with the CorDapp running locally from your Corda cluster. You can test the connection by click on the dropdown list at the Flow Initiator section. You should be able to see the vNodes of your started CorDapp. You can easily trigger and query a Corda flow. ![image](https://github.com/corda/cordapp-template-kotlin/assets/51169685/88e6568e-49b4-46a8-b1e1-34140bcf03a9) ## Running the Chat app We have built a simple one to one chat app to demo some functionalities of the next gen Corda platform. In this app you can: 1. Create a new chat with a counterparty. `CreateNewChatFlow` 2. List out the chat entries you had. `ListChatsFlow` 3. Individually query out the history of one chat entry. `GetChatFlowArgs` 4. Continue chatting within the chat entry with the counterparty. `UpdateChatFlow` ### Running the chat app In Corda 5, flows will be triggered via `POST /flow/{holdingidentityshorthash}` and flow result will need to be view at `GET /flow/{holdingidentityshorthash}/{clientrequestid}` * holdingidentityshorthash: the id of the network participants, ie Bob, Alice, Charlie. You can view all the short hashes of the network member with another gradle task called `listVNodes` * clientrequestid: the id you specify in the flow requestBody when you trigger a flow. #### Step 1: Create Chat Entry Pick a VNode identity to initiate the chat, and get its short hash. (Let's pick Alice. Dont pick Bob because Bob is the person who we will have the chat with). Go to `POST /flow/{holdingidentityshorthash}`, enter the identity short hash(Alice's hash) and request body: ``` { "clientRequestId": "create-1", "flowClassName": "com.r3.developers.cordapptemplate.utxoexample.workflows.CreateNewChatFlow", "requestBody": { "chatName":"Chat with Bob", "otherMember":"CN=Bob, OU=Test Dept, O=R3, L=London, C=GB", "message": "Hello Bob" } } ``` After trigger the create-chat flow, hop to `GET /flow/{holdingidentityshorthash}/{clientrequestid}` and enter the short hash(Alice's hash) and clientrequestid to view the flow result #### Step 2: List the chat In order to continue the chat, we would need the chat ID. This step will bring out all the chat entries this entity (Alice) has. Go to `POST /flow/{holdingidentityshorthash}`, enter the identity short hash(Alice's hash) and request body: ``` { "clientRequestId": "list-1", "flowClassName": "com.r3.developers.cordapptemplate.utxoexample.workflows.ListChatsFlow", "requestBody": {} } ``` After trigger the list-chats flow, again, we need to hop to `GET /flow/{holdingidentityshorthash}/{clientrequestid}` and check the result. As the screenshot shows, in the response body, we will see a list of chat entries, but it currently only has one entry. And we can see the id of the chat entry. Let's record that id. #### Step 3: Continue the chat with `UpdateChatFlow` In this step, we will continue the chat between Alice and Bob. Goto `POST /flow/{holdingidentityshorthash}`, enter the identity short hash and request body. Note that here we can have either Alice or Bob's short hash. If you enter Alice's hash, this message will be recorded as a message from Alice, vice versa. And the id field is the chat entry id we got from the previous step. ``` { "clientRequestId": "update-1", "flowClassName": "com.r3.developers.cordapptemplate.utxoexample.workflows.UpdateChatFlow", "requestBody": { "id":" ** fill in id **", "message": "How are you today?" } } ``` And as for the result of this flow, go to `GET /flow/{holdingidentityshorthash}/{clientrequestid}` and enter the required fields. #### Step 4: See the whole chat history of one chat entry After a few back and forth of the messaging, you can view entire chat history by calling GetChatFlow. ``` { "clientRequestId": "get-1", "flowClassName": "com.r3.developers.cordapptemplate.utxoexample.workflows.GetChatFlow", "requestBody": { "id":" ** fill in id **", "numberOfRecords":"4" } } ``` And as for the result, you need to go to the Get API again and enter the short hash and client request ID. Thus, we have concluded a full run through of the chat app.
0
marcelocf/janusgraph_tutorial
Tutorial with example code on how to get started with JanusGraph
null
> *WARNING:* this is *old*. Very very old! It shouldn't work and information here is vely very wrong as of 2022. Apologies for that. > Will leave repo live for now for historic reasons, but yeah; please don't expect this to work anymore. # JanusGraph tutorial **NOTE:** it goes without saying that you need a properly configured JDK in your environment. This is a hands on guide for JanusGraph. It is organized in sections (each folder is an independent project with a section) and it is expected you follow each guide in order. ## Starging Janus Graph Every code here assumes you are running JanusGraph 0.1.0 locally. ### For the lazy You should be ashamed. BUT, here is a shortcut: ```bash ./start_janus.sh ``` ### For the ones that want to really learn stuff This is fairly simple; just download janus and tell it to start up. ```bash $ wget https://github.com/JanusGraph/janusgraph/releases/download/v0.1.0/janusgraph-0.1.0-hadoop2.zip $ unzip janusgraph-0.1.0-hadoop2.zip $ cd janusgraph-0.1.0-hadoop2/ $ ./bin/janusgraph.sh start ``` The last command should output: ``` Forking Cassandra... Running `nodetool statusthrift`.. OK (returned exit status 0 and printed string "running"). Forking Elasticsearch... Connecting to Elasticsearch (127.0.0.1:9300)... OK (connected to 127.0.0.1:9300). Forking Gremlin-Server... Connecting to Gremlin-Server (127.0.0.1:8182)..... OK (connected to 127.0.0.1:8182). Run gremlin.sh to connect. ``` Meaning you have cassandra and elasticsearch listening on the loopback interface. This is important for the examples to work. If you need to clean your data: 1. stop janus graph 1. `rm -rf db` 1. start janus graph It is also recommended that you read: * [GraphDB - diving into JanusGraph part 1](https://medium.com/finc-engineering/graph-db-diving-into-janusgraph-part-1f-199b807697d2) (3 min read) * [GraphDB - diving into JanusGraph part 2](https://medium.com/finc-engineering/graph-db-diving-into-janusgraph-part-2-f4b9cbd967ac) (4 min read) ## Why I wrote this guide after trying to find my way through this technology. I had to learn it because the traditional tools were not enough for the kind of data processing required in the task assigned to me. JanusGraph has proven to be a solid and reliable solution to our project and I hope this guide is useful for you. This is by no means a complete guide to JanusGraph. But I believe that following this using the [official documentation](http://docs.janusgraph.org/latest/) as a reference is enough framework for you to really dive into this technology. ## Scope On this tutorial we will build the backend database of a twitter clone. The sections are divided into: 1. basic schema 1. data loading 1. querying 1. hadoop integration 1. indexing for performance By the end of this tutorial you should be able to design your own (very simple but functional) database backend using JanusGraph. There is also a last section included with some recommended experiments for after you are done. ## Code Every Java code depends on the main schema class. This is a design decision to reuse code and have more consistency in naming. Also, by doing so, we avoid usage of hard coded Strings as much as possible. To ease your life, there is a simple shell script in each section called `run.sh`. This will build and evoke the example code for you. ### Java We are using the standard gradle application plugin naming conventions on Java projects; this means that we have the folders: ``` /src/main/ dist resources java ``` Inside `dist` you will find the JanusGraph configuration files. Each section has its own files. In `resources` there is the `log4j.properties` file. And `java` contains the implementation. ### Ruby In our ruby example codes we are relying on: * [RVM](https://rvm.io/): for ruby version management (if you use someting different, please prepare your env). * bundler (`gem install bundler`): for dependency management. * [gremlin driver gem](https://github.com/marcelocf/gremlin_client): a really simple driver in ruby for JanusGraph.
1
AgilData/mesos-docker-tutorial
Tutorial on building a Mesos framework in Java to launch Docker containers on slaves
null
mesos-docker-tutorial ===================== Tutorial on building a Mesos framework in Java to launch Docker containers on slaves. The full tutorial will be available on the CodeFutures web site shortly. Here are some brief instructions to running this code. First, install mesos 0.20.1 and Docker 1.0.0 or greater. This code was tested with Docker 1.2.0. Start the Mesos master and slave: nohup mesos-master --ip=127.0.0.1 --work_dir=/tmp >mesos-master.log 2>&1 & nohup mesos-slave --master=127.0.0.1:5050 --containerizers=docker,mesos >mesos-slave.log 2>&1 & Build the framework: mvn package Run the framework: java -classpath target/cf-tutorial-mesos-docker-1.0-SNAPSHOT-jar-with-dependencies.jar com.codefutures.tutorial.mesos.docker.ExampleFramework 127.0.0.1:5050 fedora/apache 2
1
thymeleaf/thymeleafexamples-stsm
Spring Thyme Seedstarter Manager - Companion application for the Thymeleaf + Spring 3" tutorial downloadable at the Thymeleaf website: http://www.thymeleaf.org/documentation.html"
null
null
1
hakdogan/jenkins-pipeline
:chart_with_upwards_trend: Learn how to implement container technologies with your Jenkins CI/CD workflows to make them easier to manage in this tutorial.
continuous-delivery continuous-integration docker docker-compose jenkins jenkins-pipeline
!["Docker Pulls](https://img.shields.io/docker/pulls/hakdogan/jenkins-pipeline.svg) [![Analytics](https://ga-beacon.appspot.com/UA-110069051-1/jenkins-pipeline/readme)](https://github.com/igrigorik/ga-beacon) # A tutorial about Continuous Integration and Continuous Delivery by Dockerize Jenkins Pipeline This repository is a tutorial it tries to exemplify how to automatically manage the process of building, testing with the highest coverage, and deployment phases. Our goal is to ensure our pipeline works well after each code being pushed. The processes we want to auto-manage: * Code checkout * Run tests * Compile the code * Run Sonarqube analysis on the code * Create Docker image * Push the image to Docker Hub * Pull and run the image ## First step, running up the services Since one of the goals is to obtain the ``sonarqube`` report of our project, we should be able to access sonarqube from the jenkins service. ``Docker compose`` is a best choice to run services working together. We configure our application services in a yaml file as below. ``docker-compose.yml`` ```yml version: '3.2' services: sonarqube: build: context: sonarqube/ ports: - 9000:9000 - 9092:9092 container_name: sonarqube jenkins: build: context: jenkins/ privileged: true user: root ports: - 8080:8080 - 50000:50000 container_name: jenkins volumes: - /tmp/jenkins:/var/jenkins_home #Remember that, the tmp directory is designed to be wiped on system reboot. - /var/run/docker.sock:/var/run/docker.sock depends_on: - sonarqube ``` Paths of docker files of the containers are specified at context attribute in the docker-compose file. Content of these files as follows. ``sonarqube/Dockerfile`` ``` FROM sonarqube:6.7-alpine ``` ``jenkins/Dockerfile`` ``` FROM jenkins:2.60.3 ``` If we run the following command in the same directory as the ``docker-compose.yml`` file, the Sonarqube and Jenkins containers will up and run. ``` docker-compose -f docker-compose.yml up --build ``` ``` docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 87105432d655 pipeline_jenkins "/bin/tini -- /usr..." About a minute ago Up About a minute 0.0.0.0:8080->8080/tcp, 0.0.0.0:50000->50000/tcp jenkins f5bed5ba3266 pipeline_sonarqube "./bin/run.sh" About a minute ago Up About a minute 0.0.0.0:9000->9000/tcp, 0.0.0.0:9092->9092/tcp sonarqube ``` ## GitHub configuration We’ll define a service on Github to call the ``Jenkins Github webhook`` because we want to trigger the pipeline. To do this go to _Settings -> Integrations & services._ The ``Jenkins Github plugin`` should be shown on the list of available services as below. ![](images/001.png) After this, we should add a new service by typing the URL of the dockerized Jenkins container along with the ``/github-webhook/`` path. ![](images/002.png) The next step is that create an ``SSH key`` for a Jenkins user and define it as ``Deploy keys`` on our GitHub repository. ![](images/003.png) If everything goes well, the following connection request should return with a success. ``` ssh git@github.com PTY allocation request failed on channel 0 Hi <your github username>/<repository name>! You've successfully authenticated, but GitHub does not provide shell access. Connection to github.com closed. ``` ## Jenkins configuration We have configured Jenkins in the docker compose file to run on port 8080 therefore if we visit http://localhost:8080 we will be greeted with a screen like this. ![](images/004.png) We need the admin password to proceed to installation. It’s stored in the ``/var/jenkins_home/secrets/initialAdminPassword`` directory and also It’s written as output on the console when Jenkins starts. ``` jenkins | ************************************************************* jenkins | jenkins | Jenkins initial setup is required. An admin user has been created and a password generated. jenkins | Please use the following password to proceed to installation: jenkins | jenkins | 45638c79cecd4f43962da2933980197e jenkins | jenkins | This may also be found at: /var/jenkins_home/secrets/initialAdminPassword jenkins | jenkins | ************************************************************* ``` To access the password from the container. ``` docker exec -it jenkins sh / $ cat /var/jenkins_home/secrets/initialAdminPassword ``` After entering the password, we will download recommended plugins and define an ``admin user``. ![](images/005.png) ![](images/006.png) ![](images/007.png) After clicking **Save and Finish** and **Start using Jenkins** buttons, we should be seeing the Jenkins homepage. One of the seven goals listed above is that we must have the ability to build an image in the Jenkins being dockerized. Take a look at the volume definitions of the Jenkins service in the compose file. ``` - /var/run/docker.sock:/var/run/docker.sock ``` The purpose is to communicate between the ``Docker Daemon`` and the ``Docker Client``(_we will install it on Jenkins_) over the socket. Like the docker client, we also need ``Maven`` to compile the application. For the installation of these tools, we need to perform the ``Maven`` and ``Docker Client`` configurations under _Manage Jenkins -> Global Tool Configuration_ menu. ![](images/008.png) We have added the ``Maven and Docker installers`` and have checked the ``Install automatically`` checkbox. These tools are installed by Jenkins when our script([Jenkins file](https://github.com/hakdogan/jenkins-pipeline/blob/master/Jenkinsfile)) first runs. We give ``myMaven`` and ``myDocker`` names to the tools. We will access these tools with this names in the script file. Since we will perform some operations such as ``checkout codebase`` and ``pushing an image to Docker Hub``, we need to define the ``Docker Hub Credentials``. Keep in mind that if we are using a **private repo**, we must define ``Github credentials``. These definitions are performed under _Jenkins Home Page -> Credentials -> Global credentials (unrestricted) -> Add Credentials_ menu. ![](images/009.png) We use the value we entered in the ``ID`` field to Docker Login in the script file. Now, we define pipeline under _Jenkins Home Page -> New Item_ menu. ![](images/010.png) In this step, we select ``GitHub hook trigger for GITScm pooling`` options for automatic run of the pipeline by ``Github hook`` call. ![](images/011.png) Also in the Pipeline section, we select the ``Pipeline script from SCM`` as Definition, define the GitHub repository and the branch name, and specify the script location (_[Jenkins file](https://github.com/hakdogan/jenkins-pipeline/blob/master/Jenkinsfile)_). ![](images/012.png) After that, when a push is done to the remote repository or when you manually trigger the pipeline by ``Build Now`` option, the steps described in Jenkins file will be executed. ![](images/013.png) ## Review important points of the Jenkins file ``` stage('Initialize'){ def dockerHome = tool 'myDocker' def mavenHome = tool 'myMaven' env.PATH = "${dockerHome}/bin:${mavenHome}/bin:${env.PATH}" } ``` The ``Maven`` and ``Docker client`` tools we have defined in Jenkins under _Global Tool Configuration_ menu are added to the ``PATH environment variable`` for using these tools with ``sh command``. ``` stage('Push to Docker Registry'){ withCredentials([usernamePassword(credentialsId: 'dockerHubAccount', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) { pushToImage(CONTAINER_NAME, CONTAINER_TAG, USERNAME, PASSWORD) } } ``` ``withCredentials`` provided by ``Jenkins Credentials Binding Plugin`` and bind credentials to variables. We passed **dockerHubAccount** value with ``credentialsId`` parameter. Remember that, dockerHubAccount value is Docker Hub credentials ID we have defined it under _Jenkins Home Page -> Credentials -> Global credentials (unrestricted) -> Add Credentials_ menu. In this way, we access to the username and password information of the account for login. ## Sonarqube configuration For ``Sonarqube`` we have made the following definitions in the ``pom.xml`` file of the project. ```xml <sonar.host.url>http://sonarqube:9000</sonar.host.url> ... <dependencies> ... <dependency> <groupId>org.codehaus.mojo</groupId> <artifactId>sonar-maven-plugin</artifactId> <version>2.7.1</version> <type>maven-plugin</type> </dependency> ... </dependencies> ``` In the docker compose file, we gave the name of the Sonarqube service which is ``sonarqube``, this is why in the ``pom.xml`` file, the sonar URL was defined as http://sonarqube:9000.
0
vonzhou/SpringMVCTutorial
<Spring MVC: a Tutorial Series>(Spring MVC学习指南)
null
# 《Spring MVC学习指南》实践 --- 英文:Spring MVC: a Tutorial Series ![](face.jpg) 利用两条时间把这边书过了一遍,系统讲Spring MVC的书不多,该书比较简单清晰,看完之后至少知道该如何下手,但是深度方面需要自己的积淀。 内容包括: ```xml <modules> <!--Spring依赖注入入门--> <module>chapter01</module> <!--简单Servlet处理逻辑--> <module>chapter02a</module> <!--解耦,引入DispatcherServlet--> <module>chapter02b</module> <!--Validator的引入--> <module>chapter02c</module> <!--第一个Spring MVC应用--> <module>chapter03a</module> <!--使用view resolver--> <module>chapter03b</module> <!--使用RequestMapper和Controller注解--> <module>chapter04a</module> <!--使用Autowired和Service注解进行依赖注入--> <module>chapter04b</module> <!--使用Spring表单,数据绑定--> <module>chapter05</module> <!--Converter, Formatter使用--> <module>chapter06a</module> <!--Formatter专用于把String转为其他对象--> <module>chapter06b</module> <!--Spring的验证器使用--> <module>chapter07a</module> <!--JSR303 Validator--> <module>chapter07b</module> <!--使用JSTL标签库--> <module>chapter09</module> <!--国际化--> <module>chapter10</module> <!--使用commons-fileupload文件上传--> <module>chapter11a</module> <!--使用Servlet 3上传文件--> <module>chapter11b</module> <!--下载文件--> <module>chapter12</module> </modules> ```
1
AbbasHassan/PlacesProject
Source code for video tutorial available at: https://www.youtube.com/watch?v=ifoVBdtXsv0
null
null
1
haedri/shadow-mapping
Shadow mapping tutorial for LibGdx
null
null
1