spring boot basic example

Example 1: log4j with spring boot restful services

<!-- Rolling File Appender -->
<RollingFile name="FileAppender" fileName="logs/log4j2-demo.log" 
             filePattern="logs/log4j2-demo-%d{yyyy-MM-dd}-%i.log">
    <PatternLayout>
        <Pattern>${LOG_PATTERN}</Pattern>
    </PatternLayout>
    <Policies>
        <SizeBasedTriggeringPolicy size="10MB" />
    </Policies>
    <DefaultRolloverStrategy max="10"/>
</RollingFile>

Example 2: spring boot routing examples

@RestController
public class OrderController {
    @RequestMapping(value = "/customers/{cid}/orders/{oid}", method = GET)
    public Order getOrder(@PathVariable int cid, @PathVariable int oid) {
        ...
    }
}

Tags:

Java Example