001// *************************************************************************************************************************** 002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * 003// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * 004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * 005// * with the License. You may obtain a copy of the License at * 006// * * 007// * http://www.apache.org/licenses/LICENSE-2.0 * 008// * * 009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * 010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * 011// * specific language governing permissions and limitations under the License. * 012// *************************************************************************************************************************** 013package org.apache.juneau.examples.rest.springboot; 014 015import org.apache.juneau.examples.rest.*; 016import org.apache.juneau.rest.springboot.*; 017import org.apache.juneau.rest.springboot.annotation.*; 018import org.springframework.boot.autoconfigure.SpringBootApplication; 019import org.springframework.boot.builder.*; 020import org.springframework.boot.web.servlet.*; 021import org.springframework.context.annotation.*; 022import org.springframework.stereotype.Controller; 023import org.springframework.web.filter.*; 024 025/** 026 * Entry point for Examples REST application when deployed as a Spring Boot application. 027 */ 028@SpringBootApplication 029@Controller 030public class App { 031 032 public static void main(String[] args) { 033 new SpringApplicationBuilder(App.class) 034 .initializers(new JuneauRestInitializer(App.class)) 035 .run(args); 036 037 System.err.println(System.getProperty("server.port")); 038 } 039 040 /** 041 * Our root resource. 042 */ 043 @Bean @JuneauRestRoot 044 public RootResources getRootResources() { 045 return new RootResources(); 046 } 047 048 /** 049 * We want to be able to consume url-encoded-form-post bodies, but HiddenHttpMethodFilter triggers the HTTP 050 * body to be consumed. So disable it. 051 */ 052 @Bean 053 public FilterRegistrationBean<HiddenHttpMethodFilter> registration(HiddenHttpMethodFilter filter) { 054 FilterRegistrationBean<HiddenHttpMethodFilter> registration = new FilterRegistrationBean<>(filter); 055 registration.setEnabled(false); 056 return registration; 057 } 058}