记得上下班打卡 | git大法好,push需谨慎

Commit 613f42ea authored by 张国柄's avatar 张国柄

opt;

parent 32ae5bea
//package com.liquidnet.common.web.filter;
//
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.context.annotation.Configuration;
//
//import javax.servlet.*;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//
//@Slf4j
//@Configuration
//public class CrossDomainFilter implements Filter {
//
//
// @Override
// public void init(FilterConfig filterConfig) throws ServletException {
//
// }
//
// @Override
// public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
// HttpServletResponse resp = (HttpServletResponse)servletResponse;
// HttpServletRequest req = (HttpServletRequest)servletRequest;
// //获取请求的源
// String url = req.getHeader("Origin");
// resp.setHeader("Access-Control-Allow-Origin", url);
// resp.setHeader("Access-Control-Allow-Headers", "X-Requested-With, accept, content-type, token, xxxx");
// resp.setHeader("Access-Control-Allow-Methods", "GET, HEAD, POST, PUT, DELETE, TRACE, OPTIONS, PATCH");
// resp.setHeader("Access-Control-Allow-Credentials", "true");
// HttpServletRequest httpServletRequest = (HttpServletRequest) servletRequest;
// String requestMethod = httpServletRequest.getMethod();
// if ("OPTIONS".equalsIgnoreCase(requestMethod)) {
// return;
// }
// filterChain.doFilter(servletRequest, servletResponse);
// }
//
// @Override
// public void destroy() {
//
// }
//}
package com.liquidnet.common.web.util;
import org.springframework.boot.SpringApplication;
import org.springframework.core.env.Environment;
import java.util.HashMap;
import java.util.Map;
/**
* Utility class to load a Spring profile to be used as default
* when there is no <code>spring.profiles.active</code> set in the environment or as command line argument.
* If the value is not available in <code>application.yml</code> then <code>dev</code> profile will be used as default.
*/
public final class DefaultProfileUtil {
private static final String SPRING_PROFILE_DEFAULT = "spring.profiles.default";
private static final String SPRING_PROFILE_DEVELOPMENT ="dev";
private DefaultProfileUtil() {
}
/**
* Set a default to use when no profile is configured.
*
* @param app the Spring application
*/
public static void addDefaultProfile(SpringApplication app) {
Map<String, Object> defProperties = new HashMap<>();
/*
* The default profile to use when no other profiles are defined
* This cannot be set in the <code>application.yml</code> file.
* See https://github.com/spring-projects/spring-boot/issues/1219
*/
defProperties.put(SPRING_PROFILE_DEFAULT, SPRING_PROFILE_DEVELOPMENT);
app.setDefaultProperties(defProperties);
}
/**
* Get the profiles that are applied else get default profiles.
*
* @param env spring environment
* @return profiles
*/
public static String[] getActiveProfiles(Environment env) {
String[] profiles = env.getActiveProfiles();
if (profiles.length == 0) {
return env.getDefaultProfiles();
}
return profiles;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment