package org.araymond.joal.web.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.DispatcherServlet;

/**
 * Created by raymo on 25/07/2017.
 */
@Configuration
public class EndpointObfuscatorConfiguration {

    private final String pathPrefix;

    public EndpointObfuscatorConfiguration(@Value("${joal.ui.path.prefix}")final String pathPrefix) {
        this.pathPrefix = pathPrefix;
    }

    @Bean
    public DispatcherServlet dispatcherServlet() {
        return new DispatcherServlet();
    }

    @Bean
    public ServletRegistrationBean dispatcherServletRegistration() {
        final ServletRegistrationBean registration = new ServletRegistrationBean(
                dispatcherServlet(),
                "/" + this.pathPrefix + "/*"
        );
        registration.setName(DispatcherServletAutoConfiguration.DEFAULT_DISPATCHER_SERVLET_REGISTRATION_BEAN_NAME);
        return registration;
    }
}

@@ -91,16 +91,95 @@
 .Value;%0A
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;%0A
 import o
@@ -540,16 +540,99 @@
 17.%0A */%0A
+@ConditionalOnProperty(name = %22spring.main.web-environment%22, havingValue = %22true%22)%0A
 @Configu

Add conditionnalOn to EndpointObfuscator ensure it won't be avaiable in non-web context