spring boot quickstart
TRANSCRIPT
2
About me
Jonas Hecht, Senior IT-Consultant
https://blog.codecentric.de/author/jonas-hecht/ [email protected]
@jonashackt
github.com/jonashackt
5
http://projects.spring.io/spring-boot https://github.com/spring-projects/spring-boot http://start.spring.io/ https://spring.io/blog/2016/07/28/spring-boot-1-4-released
Where to start?
8
http://projects.spring.io/spring-boot/
“Spring Boot […] is designed to get you up and running as
quickly as possible.”
15
$ java -jar cxf-boot-simple-0.0.1-SNAPSHOT.jar !or !$ mvn spring-boot:run!
Stand-alone, no deployment
18
● Batch, Messaging, Caching, Relational Databases, JPA, NoSQL, whatever, Redis, Integration, Logging, WebServices, Mail, Security, Webapps, REST,…
● official: https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters
● community:
https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters#community-contributions
'starter' POMs
21
import org.springframework.boot.autoconfigure.condition.*; @Configuration annotated Classes: @Conditional @ConditionalOnBean(YourClassHere.class) @ConditionalOnProperty(“your.property.here“) @ConditionalOnResource ...
Automatic configuration
27
Howto: https://blog.codecentric.de/en/2014/11/extending-spring-boot-five-steps-writing-spring-boot-starter/ Examples: https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters#community-contributions https://github.com/codecentric/spring-boot-starter-batch-web https://github.com/codecentric/cxf-spring-boot-starter
Custom Spring Boot Starters
29
Complete Howto: https://blog.codecentric.de/2016/02/spring-boot-apache-cxf/ à http://start.spring.io/ group: de.codecentric.webservice artifact: simpleservice Web & Devtools
Demo: web service with Apache CXF 1/4
CXF-Dependencies <!-- Apache CXF --> <dependency>
<groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-frontend-jaxws</artifactId> <version>3.1.7</version>
</dependency> <dependency>
<groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-transports-http</artifactId> <version>3.1.7</version>
</dependency>
30
Demo: web service with Apache CXF 2/4
@Bean public ServletRegistrationBean dispatcherServlet() { return new ServletRegistrationBean(new CXFServlet(), "/soap-api/*"); } @Bean(name= Bus.DEFAULT_BUS_ID) public SpringBus springBus() { return new SpringBus(); }
31
WSDL: https://github.com/jonashackt/weather-service-wsdl/ jaxws-maven-plugin config see https://blog.codecentric.de/2016/02/spring-boot-apache-cxf/ http://cxf.apache.org/docs/jax-ws-configuration.html
Demo: web service with Apache CXF 3/4
32
@Bean public WeatherService weatherService() { return new WeatherServiceEndpoint(); } @Bean public Endpoint endpoint() { EndpointImpl endpoint = new EndpointImpl(springBus(), weatherService()); endpoint.publish("/WeatherSoapService_1.0"); return endpoint; }
Demo: web service with Apache CXF 4/4