# java latest (>=9)
$ brew cask info java
$ brew cask install java
# java specific version (e.g. java8)
$ brew tap caskroom/versions
$ brew cask search "java*"
$ brew cask install java8 # you may need to change JAVA_HOME afterwards
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.demo.graphql | |
import com.coxautodev.graphql.tools.GraphQLQueryResolver | |
import org.springframework.stereotype.Component | |
import java.util.* | |
@Component | |
class PersonQueryResolver( | |
private val repo: PersonRepo | |
) : GraphQLQueryResolver { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# LobCreatorBuilderImpl : HHH000424: Disabling contextual LOB creation as createClob() method threw error | |
# see: http://vkuzel.blogspot.de/2016/03/spring-boot-jpa-hibernate-atomikos.html | |
# Disable feature detection by this undocumented parameter. Check the org.hibernate.engine.jdbc.internal.JdbcServiceImpl.configure method for more details. | |
spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults: false | |
# Because detection is disabled you have to set correct dialect by hand. | |
spring.jpa.database-platform: org.hibernate.dialect.PostgreSQL9Dialect |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.auth0utils | |
import com.auth0.jwk.JwkProviderBuilder | |
import com.auth0.jwt.JWT | |
import com.auth0.jwt.JWTVerifier | |
import com.auth0.jwt.exceptions.JWTDecodeException | |
import com.auth0.jwt.exceptions.JWTVerificationException | |
import com.auth0.jwt.interfaces.DecodedJWT | |
import com.auth0.spring.security.api.JwtAuthenticationEntryPoint | |
import com.auth0.spring.security.api.JwtAuthenticationProvider |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.testutils.beanvalidation | |
import org.hibernate.validator.HibernateValidator | |
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean | |
fun localValidatorFactoryBean():LocalValidatorFactoryBean { | |
val validator= LocalValidatorFactoryBean() | |
validator.setProviderClass(HibernateValidator::class.java) | |
validator.afterPropertiesSet() | |
return validator |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun loadResource(resource: String): String = | |
try { | |
object {}.javaClass.getResource(resource) | |
.readText(Charsets.UTF_8) | |
} catch (all: Exception) { | |
throw RuntimeException("Failed to load resource=$resource!", all) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example: jsonExpected shouldEqualJson jsonGiven | |
import com.fasterxml.jackson.databind.ObjectMapper | |
import com.fasterxml.jackson.databind.SerializationFeature | |
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module | |
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule | |
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper | |
import com.fasterxml.jackson.module.kotlin.readValue | |
import org.amshove.kluent.shouldEqual |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun <T : Any> Optional<T>.toNullable(): T? { | |
return if (this.isPresent) { | |
this.get() | |
} else { | |
null | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data class Off(val id: Int, val offName: String) | |
data class Prop(val id: Int, val propName: String, val offId: Int) | |
data class Joined(val off: Off, val props: List<Prop>) | |
fun main(args: Array<String>) { | |
val offs: List<Off> = listOf( | |
Off(id = 1, offName = "Off A"), | |
Off(id = 2, offName = "Off B") | |
) | |
val props: List<Prop> = listOf( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// see: https://github.com/auth0-blog/spring-boot-jwts/blob/master/src/main/java/com/example/security/TokenAuthenticationService.java | |
//Example: | |
val json:String= JwtUntrusted.parseClaimsUntrustedToJson("Bearer xxx") | |
object JwtUntrusted { | |
// requires (gradle): compile group: 'io.jsonwebtoken', name: 'jjwt', version: '0.9.0' | |
private val JSON = jacksonObjectMapper() | |
fun removeSignature(jwt:String) = jwt.replaceAfterLast(".", "").trim() |