https://httpie.org/
https://github.com/jakubroztocil/httpie
much more intuitive IMHO
Tuesday, June 26, 2018
Learning Spring Boot second edition
Excellent book by Greg L. Turnquist - no blabla, just stuff. Much better than the incredibly verbose and blablaistic Spring in Action.
Sample code here https://github.com/PacktPublishing/Learning-Spring-Boot-2.0-Second-Edition
You need MongoDB installed (IMHO better than using the embedded, I had issues)
https://www.mongodb.com/download-center?jmp=nav#community
download and install MongoDB community to D:\Program Files\MongoDB\Server\3.0\bin.... data by default is in D:\data\db
cd D:\Program Files\MongoDB\Server\3.0\bin
./mongod (it uses port 27017 by default)
./mongo
show dbs
show collections
db.chapter.find()
and possibly RabbitMQ:
https://www.rabbitmq.com/download.html
How to use the initializer:
https://start.spring.io/starter.zip?name=pvlearningspringboot&groupId=com.greglturnquist.learningspringboot&artifactId=pvlearningspringboot&version=1.0&description=pvlearningspringboot&packageName=com.greglturnquist.learningspringboot&type=gradle-project&packaging=war&javaVersion=1.8&language=java&bootVersion=2.0.3.RELEASE&dependencies=lombok&dependencies=data-mongodb-reactive&dependencies=thymeleaf&dependencies=webflux
Labels:
mongodb,
springboot
Thursday, June 21, 2018
Gradle and Nexus
download Gradle binaries
mkdir /home/centos/gradle
unzip -d /home/centos/gradle/ gradle-4.8-bin.zip
export PATH=$PATH:/home/centos/gradle/gradle-4.8/bin/
gradle -version
cd gitclones/
git clone https://github.com/buzdin/allure-junit5-course
cd allure-junit5-course/
vi build.gradle
replace
repositories {
jcenter()
}
with
repositories {
maven {
url "http://localhost:8181/repository/maven-public/"
}
}
if your "group" maven-public repository points only to Maven Central, the build will fail
rm -rf .gradle/
gradle build --refresh-dependencies --debug
> Could not resolve all artifacts for configuration ':classpath'.
> Could not find io.qameta.allure:allure-gradle:2.4.
Searched in the following locations:
- http://localhost:8181/repository/maven-public/io/qameta/allure/allure-gradle/2.4/allure-gradle-2.4.pom
- http://localhost:8181/repository/maven-public/io/qameta/allure/allure-gradle/2.4/allure-gradle-2.4.jar
Required by:
project :
If you add to the group also a Proxy Repo "jcenter" pointing to https://jcenter.bintray.com/, everything works
mkdir /home/centos/gradle
unzip -d /home/centos/gradle/ gradle-4.8-bin.zip
export PATH=$PATH:/home/centos/gradle/gradle-4.8/bin/
gradle -version
cd gitclones/
git clone https://github.com/buzdin/allure-junit5-course
cd allure-junit5-course/
vi build.gradle
replace
repositories {
jcenter()
}
with
repositories {
maven {
url "http://localhost:8181/repository/maven-public/"
}
}
if your "group" maven-public repository points only to Maven Central, the build will fail
rm -rf .gradle/
gradle build --refresh-dependencies --debug
> Could not resolve all artifacts for configuration ':classpath'.
> Could not find io.qameta.allure:allure-gradle:2.4.
Searched in the following locations:
- http://localhost:8181/repository/maven-public/io/qameta/allure/allure-gradle/2.4/allure-gradle-2.4.pom
- http://localhost:8181/repository/maven-public/io/qameta/allure/allure-gradle/2.4/allure-gradle-2.4.jar
Required by:
project :
If you add to the group also a Proxy Repo "jcenter" pointing to https://jcenter.bintray.com/, everything works
Wednesday, June 20, 2018
Zipkin and Sleuth distributed tracing
https://dzone.com/articles/microservices-part-6-distributed-tracing-with-spri
https://zipkin.io/
Sleuth concise presentation with example:
and code is here https://github.com/TechPrimers/spring-cloud-sleuth-example
This is a very nice real demo (not "helloworld") of Sleuth and ELK with Kibana
https://zipkin.io/
Sleuth concise presentation with example:
and code is here https://github.com/TechPrimers/spring-cloud-sleuth-example
This is a very nice real demo (not "helloworld") of Sleuth and ELK with Kibana
Sunday, June 10, 2018
Eclipse and Gradle
Importing an old Gradle project in Eclipse can be problematic. I get this error message when "import existing gradle build"
Spring Boot plugin requires Gradle 4.0 or later. The current version is Gradle 2.5
I the project's "gradle/wrapper/gradle-wrapper.properties" I replace
distributionUrl=https\://services.gradle.org/distributions/gradle-2.5-bin.zip
with
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-bin.zip
I download and install latest gradle 4.8 in E:\apps\gradle-4.8
In Eclipse, configure the Preferences/Gradle setting the Gradle User Home to E:\apps\gradle-4.8
I have installed "Buildship Eclipse plug-ins for Gradle" version 2.2.1
It's a real pity that the plugin doesn't offer an automatic resolution of the issue (upgrading to latest Gradle, and updating the project's settings", but in case of Eclipse we are just thankful it doesn't crash as it usually does. What a pathetic piece of crap Eclipse is, it's a shame for the whole IT community, I use it only because it's the official IDE at work.
Spring Boot plugin requires Gradle 4.0 or later. The current version is Gradle 2.5
I the project's "gradle/wrapper/gradle-wrapper.properties" I replace
distributionUrl=https\://services.gradle.org/distributions/gradle-2.5-bin.zip
with
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-bin.zip
I download and install latest gradle 4.8 in E:\apps\gradle-4.8
In Eclipse, configure the Preferences/Gradle setting the Gradle User Home to E:\apps\gradle-4.8
I have installed "Buildship Eclipse plug-ins for Gradle" version 2.2.1
It's a real pity that the plugin doesn't offer an automatic resolution of the issue (upgrading to latest Gradle, and updating the project's settings", but in case of Eclipse we are just thankful it doesn't crash as it usually does. What a pathetic piece of crap Eclipse is, it's a shame for the whole IT community, I use it only because it's the official IDE at work.
Thursday, June 7, 2018
Browsermob as a whitelisting/blacklisting Proxy
http://bmp.lightbody.net/
https://github.com/lightbody/browsermob-proxy
It's based on our friend Littleproxy.
Its latest release it 2.1.6. It seems not much going on recently... no commits in last 8 months...
In our case, 2 APIs are interesting:
Sets a list of URL patterns to whitelist PUT /proxy/[port]/whitelist
Request Parameters:
regex - A comma separated list of regular expressions.
status - The HTTP status code to return for URLs that do not match the whitelist.
Set a URL to blacklist PUT /proxy/[port]/blacklist
Request Parameters:
regex - The blacklist regular expression.
status - The HTTP status code to return for URLs that are blacklisted.
method - The regular expression for matching HTTP method (GET, POST, PUT, etc). Optional, by default processing all HTTP method.
https://github.com/lightbody/browsermob-proxy
It's based on our friend Littleproxy.
Its latest release it 2.1.6. It seems not much going on recently... no commits in last 8 months...
In our case, 2 APIs are interesting:
Sets a list of URL patterns to whitelist PUT /proxy/[port]/whitelist
Request Parameters:
regex - A comma separated list of regular expressions.
status - The HTTP status code to return for URLs that do not match the whitelist.
Set a URL to blacklist PUT /proxy/[port]/blacklist
Request Parameters:
regex - The blacklist regular expression.
status - The HTTP status code to return for URLs that are blacklisted.
method - The regular expression for matching HTTP method (GET, POST, PUT, etc). Optional, by default processing all HTTP method.
Labels:
blacklist,
browsermob,
httpproxy,
littleproxy,
whitelist
Saturday, June 2, 2018
Spring Boot and H2
https://dzone.com/articles/spring-boot-and-spring-jdbc-with-h2
Example code is here:
https://github.com/in28minutes/spring-boot-examples/tree/master/spring-boot-2-jdbc-with-h2
you must add spring.h2.console.path=/h2 in the application.properties file
in a nutshell:
in pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
in application.properties
To implement a repository:
import org.springframework.data.repository.CrudRepository;
public interface QuarantineRepository extends CrudRepository<Quarantine, Long> {
List findBygav(String gav);
}
To use the repository in a @javax.inject.Named bean:
import javax.inject.Inject;
...
@Inject
QuarantineRepository quarantineRepository ;
where Quarantine is like this:
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@Entity
public class Quarantine {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String gav;
etc etc
}
Example code is here:
https://github.com/in28minutes/spring-boot-examples/tree/master/spring-boot-2-jdbc-with-h2
you must add spring.h2.console.path=/h2 in the application.properties file
in a nutshell:
in pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
in application.properties
# Datasource #spring.datasource.url=jdbc:h2:file:~/test spring.datasource.url=jdbc:h2:file:~/mydb spring.datasource.username=mydb spring.datasource.password=mydb spring.datasource.driver-class-name=org.h2.Driver # H2 # Enabling H2 Console spring.h2.console.path=/h2 spring.h2.console.enabled=true #Turn Statistics on spring.jpa.properties.hibernate.generate_statistics=true logging.level.org.hibernate.stat=debug # Show all queries spring.jpa.show-sql=true spring.jpa.properties.hibernate.format_sql=true logging.level.org.hibernate.type=trace #spring.jpa.generate-ddl=false spring.jpa.hibernate.ddl-auto=update #spring.jpa.hibernate.ddl-auto=validate
To implement a repository:
import org.springframework.data.repository.CrudRepository;
public interface QuarantineRepository extends CrudRepository<Quarantine, Long> {
List
}
To use the repository in a @javax.inject.Named bean:
import javax.inject.Inject;
...
@Inject
QuarantineRepository quarantineRepository ;
where Quarantine is like this:
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@Entity
public class Quarantine {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String gav;
etc etc
}
Labels:
h2,
springboot
Spring Boot 2 actuator ... priceless!
in application.properties, add this
management.endpoints.web.exposure.include=*
management.endpoint.shutdown.enabled=true
and restart. hit this:
http://localhost:8080/actuator/beans
You can see the definition of all the Spring beans
Tutorial here http://www.baeldung.com/spring-boot-actuators
http://localhost:8080/actuator/auditevents
http://localhost:8080/actuator/conditions
http://localhost:8080/actuator/configprops
http://localhost:8080/actuator/env
http://localhost:8080/actuator/flyway (fail)
http://localhost:8080/actuator/health
http://localhost:8080/actuator/heapdump , this will save a file heapdump, rename it to heapdump.hprof, then open it with Eclipse Memory Analyzer Tool (MemoryAnalyzer.exe on Windows)
http://localhost:8080/actuator/info
http://localhost:8080/actuator/liquibase (fail)
http://localhost:8080/actuator/logfile
http://localhost:8080/actuator/loggers
http://localhost:8080/actuator/threaddump
http://localhost:8080/actuator/metrics
http://localhost:8080/actuator/metrics/jvm.memory.max
http://localhost:8080/actuator/scheduledtasks
http://localhost:8080/actuator/httptrace
http://localhost:8080/actuator/mappings
http://localhost:8080/actuator/prometheus (fail)
http://localhost:8080/actuator/sessions (fail)
http://localhost:8080/actuator/shutdown (fail)
http://localhost:8080/actuator/jolokia (fail)
management.endpoints.web.exposure.include=*
management.endpoint.shutdown.enabled=true
and restart. hit this:
http://localhost:8080/actuator/beans
You can see the definition of all the Spring beans
Tutorial here http://www.baeldung.com/spring-boot-actuators
http://localhost:8080/actuator/auditevents
http://localhost:8080/actuator/conditions
http://localhost:8080/actuator/configprops
http://localhost:8080/actuator/env
http://localhost:8080/actuator/flyway (fail)
http://localhost:8080/actuator/health
http://localhost:8080/actuator/heapdump , this will save a file heapdump, rename it to heapdump.hprof, then open it with Eclipse Memory Analyzer Tool (MemoryAnalyzer.exe on Windows)
http://localhost:8080/actuator/info
http://localhost:8080/actuator/liquibase (fail)
http://localhost:8080/actuator/logfile
http://localhost:8080/actuator/loggers
http://localhost:8080/actuator/threaddump
http://localhost:8080/actuator/metrics
http://localhost:8080/actuator/metrics/jvm.memory.max
http://localhost:8080/actuator/scheduledtasks
http://localhost:8080/actuator/httptrace
http://localhost:8080/actuator/mappings
http://localhost:8080/actuator/prometheus (fail)
http://localhost:8080/actuator/sessions (fail)
http://localhost:8080/actuator/shutdown (fail)
http://localhost:8080/actuator/jolokia (fail)
Labels:
actuator,
springboot
Friday, June 1, 2018
Nexus proxy to npm registry
https://nodejs.org/en/
https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-a-centos-7-server
Install node.js
cd ~
wget http://nodejs.org/dist/v0.10.30/node-v0.10.30-linux-x64.tar.gz
sudo tar --strip-components 1 -xzvf node-v* -C /usr/local
node --version
npm
https://help.sonatype.com/repomanager3/node-packaged-modules-and-npm-registries
In nexus 3, create a Proxy NPM repo pointing to https://registry.npmjs.org and called npm-all
npm config set registry http://localhost:8081/repository/npm-all/
npm install --save-dev babel-loader babel-core babel-preset-env webpack
it works! I only get this error
to clean npm local repository, use "npm cache clean"
https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-a-centos-7-server
Install node.js
cd ~
wget http://nodejs.org/dist/v0.10.30/node-v0.10.30-linux-x64.tar.gz
sudo tar --strip-components 1 -xzvf node-v* -C /usr/local
node --version
npm
https://help.sonatype.com/repomanager3/node-packaged-modules-and-npm-registries
In nexus 3, create a Proxy NPM repo pointing to https://registry.npmjs.org and called npm-all
npm config set registry http://localhost:8081/repository/npm-all/
npm install --save-dev babel-loader babel-core babel-preset-env webpack
it works! I only get this error
engine p-try@1.0.0: wanted: {"node":">=4"} (current: {"node":"0.10.30","npm":"1.4.21"})
npm ERR! Error: Package 'webassemblyjs-ast' not found : repository/npm-all/webassemblyjs/ast
npm ERR! at RegClient. (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:300:14)
npm ERR! at Request._callback (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:238:65)
npm ERR! at Request.self.callback (/usr/local/lib/node_modules/npm/node_modules/request/request.js:123:22)
npm ERR! at Request.emit (events.js:98:17)
npm ERR! at Request. (/usr/local/lib/node_modules/npm/node_modules/request/request.js:893:14)
npm ERR! at Request.emit (events.js:117:20)
npm ERR! at IncomingMessage. (/usr/local/lib/node_modules/npm/node_modules/request/request.js:844:12)
npm ERR! at IncomingMessage.emit (events.js:117:20)
npm ERR! at _stream_readable.js:938:16
npm ERR! at process._tickCallback (node.js:419:13)
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR!
to clean npm local repository, use "npm cache clean"
Subscribe to:
Comments (Atom)
