GVKun编程网logo

java web 获取客户端外网 ip 和所在区域(java获取外网ip地址)

1

以上就是给各位分享javaweb获取客户端外网ip和所在区域,其中也会对java获取外网ip地址进行解释,同时本文还将给你拓展.NETWeb部件|Web部件管理器|Web部件区、.net获取客户端外网

以上就是给各位分享java web 获取客户端外网 ip 和所在区域,其中也会对java获取外网ip地址进行解释,同时本文还将给你拓展.NET Web 部件 | Web 部件管理器 | Web 部件区、.net 获取客户端外网 ip、Airflow/Pentaho Java 错误 - 启动 mvn 时出错:org.ops4j.pax.web/pax-web-runtime/7.2.10、asp.net-web-api – System.Web.Routing.RouteCollection不包含“MapHttpRoute”的定义 – VS 2012,Web API等相关知识,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

java web 获取客户端外网 ip 和所在区域(java获取外网ip地址)

java web 获取客户端外网 ip 和所在区域(java获取外网ip地址)

@参考文章 1、@参考文章 2、@参考文章 3、@参考文章 4,@之前同事的项目

 controller

@Controller
@RequestMapping("/home")
public class HomeController {
    @RequestMapping("/")
    public String index(HttpServletRequest req) {
        try {
            String ip = IpUtil.getOuterNetIp(req);//获取外网ip
            System.out.println(ip);
            String ipCity = IpUtil.getIpArea(ip);//根据外网ip获取所在区域
            System.out.println(ipCity);
            req.setAttribute("ipCity", ipCity);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "home";
    }
}
View Code

IpUtil

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.Charset;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang3.StringUtils;
import org.json.JSONException;
import org.json.JSONObject;

import sun.net.util.IPAddressUtil;

/**
 * @todo ip工具类
 * @author yanan
 * @date 2018年11月12日
 */
public class IpUtil {
    
    /**
     * @todo 获取外网ip所在区域 
     * @param 
     * @date 2018年11月12日
     * @author yanan
     */
    public static String getIpArea(String ip) throws Exception {
        // 淘宝的ip定位
        JSONObject json = readJsonFromUrl("http://ip.taobao.com/service/getIpInfo.php?ip=" + ip);
        if (json.has("code")) {
            if ((json.get("code").toString().trim()).equalsIgnoreCase("0")) {
                String strIp = ((JSONObject) json.get("data")).get("city").toString();
                return strIp;
            } else {
                return "郑州";
            }
        } else {
            return "郑州";
        }
    }
    /**
     * @todo 百度api ip接口
     * @param
     * @date 2018年11月9日
     * @author yanan
     */
    public static JSONObject readJsonFromUrl(String url) throws Exception, JSONException {
        InputStream is = null;
        try {
            URL ul = new URL(url); // 创建 URL
            HttpURLConnection urlCon = (HttpURLConnection) ul.openConnection();
            urlCon.setConnectTimeout(2000);
            urlCon.setReadTimeout(2000);
            // Long b = System.currentTimeMillis();
            is = urlCon.getInputStream(); // 打开到这个URL的流
            // System.out.println("获取百度api
            // ip接口:="+(System.currentTimeMillis()-b));
            BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
            String jsonText = readAll(rd);
            JSONObject json = new JSONObject(jsonText);
            return json;
        } catch (Exception e) {
            e.printStackTrace();
            JSONObject jsonObj = new JSONObject();
            jsonObj.put("status", "1");
            // System.out.println("new jsonObj status=0,new jsonObj status=0new
            // jsonObj status=0new jsonObj status=0");
            return jsonObj;
        } finally {
            if (null != is)
                is.close();
        }
    }
    /**
     * @todo 将输入流转换成字符串
     * @param
     * @date 2018年11月9日
     * @author yanan
     */
    private static String readAll(Reader rd) throws IOException {
        StringBuilder sb = new StringBuilder();
        int cp;
        while ((cp = rd.read()) != -1) {
            sb.append((char) cp);
        }
        return sb.toString();
    }

    
    /**
     * @todo  获取外网ip
     * @param 
     * @date 2018年11月12日
     * @author yanan
     * @throws Exception 
     */
    public static String getOuterNetIp(final HttpServletRequest request) throws Exception {
        String ipAddr = getIpAddr(request);//获取ip地址
        boolean internalIp = internalIp(ipAddr);//判断ip是否内网ip
        if(!internalIp){//外网地址直接返回
            return ipAddr;
        }
        String result = "";
        URLConnection connection;
        BufferedReader in = null;
        try {
            URL url = new URL("http://www.icanhazip.com");
            connection = url.openConnection();
            connection.setRequestProperty("accept", "*/*");
            connection.setRequestProperty("connection", "KeepAlive");
            connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
            connection.setConnectTimeout(3000);
            connection.setReadTimeout(3000);
            connection.connect();
            in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            String line;
            while ((line = in.readLine()) != null) {
                result += line;
            }
        } catch (MalformedURLException e) {
        } catch (IOException e) {
        } finally {
            try {
                if (in != null) {
                    in.close();
                }
            } catch (IOException e) {
            }
        }
        return result;
    }
    /**
     * @todo 判断是否内网ip
     * @param 
     * @date 2018年11月12日
     * @author yanan
     */
    public static boolean internalIp(String ip) {
        if ("127.0.0.1".equalsIgnoreCase(ip))
            return true;
        if ("0:0:0:0:0:0:0:1".equals(ip))
            return true;
        byte[] addr = IPAddressUtil.textToNumericFormatV4(ip);
        return internalIp(addr);
    }
    /**
     * @todo 判断解析后的ip是否内网
     * @param 
     * @date 2018年11月12日
     * @author yanan
     */
    public static boolean internalIp(byte[] addr) {
        final byte b0 = addr[0];
        final byte b1 = addr[1];
        // 10.x.x.x/8
        final byte SECTION_1 = 0x0A;
        // 172.16.x.x/12
        final byte SECTION_2 = (byte) 0xAC;
        final byte SECTION_3 = (byte) 0x10;
        final byte SECTION_4 = (byte) 0x1F;
        // 127.0.0.1/16
        final byte SECTION_5 = (byte) 0xC0;
        final byte SECTION_6 = (byte) 0xA8;
        switch (b0) {
        case SECTION_1:
            return true;
        case SECTION_2:
            if (b1 >= SECTION_3 && b1 <= SECTION_4) {
                return true;
            }
        case SECTION_5:
            switch (b1) {
            case SECTION_6:
                return true;
            }
        default:
            return false;
        }
    }
    /**
     * @todo 获取ip地址
     * @param 
     * @date 2018年11月12日
     * @author yanan
     */
    public static final String getIpAddr(final HttpServletRequest request) throws Exception {
        if (request == null) {
            throw (new Exception("======================request为null======================"));
        }
        /**
         * 在JSP里,获取客户端的IP地址的方法是:request.getRemoteAddr() 
         * 这种方法在大部分情况下都是有效的。但是在通过了Apache,Squid等反向代理软件就不能获取到客户端的真实IP地址了。
         * 经过代理以后,由于在客户端和服务之间增加了中间层,因此服务器无法直接拿到客户端的IP,服务器端应用也无法直接通过
         * 转发请求的地址返回给客户端。但是在转发请求的HTTP头信息中,增加了X-FORWARDED-FOR等信息。用以跟踪原有的客户
         * 端IP地址和原来客户端请求的服务器地址。
         * 假定客户端通过多级代理,最终到达服务器端(nginx,squid,haproxy);此时经过多级反向的代理,
         * 通过方法getRemoteAddr(),得不到客户端真实IP,可以通过x-forwarded-for等获得转发后请求信息。
         * 因此获取ip的步骤应为:先获取各种代理服务器ip,若为空再获取request.getRemoteAddr() 
         */
        
        //x-forwarded-for是一个 Squid 开发的字段,只有在通过了HTTP代理或者负载均衡服务器时才会添加该项。当客户端请求被转发,
        //格式为X-Forwarded-For:client1,proxy1,proxy2,一般情况下,第一个ip为客户端真实ip,
        //IP将会追加在其后并以逗号隔开,后面的为经过的代理服务器ip。现在大部分的代理都会加上这个请求头。
        String ipString = request.getHeader("x-forwarded-for");
        //用apache http做代理时一般会加上Proxy-Client-IP请求头
        if (StringUtils.isBlank(ipString) || "unknown".equalsIgnoreCase(ipString)) {
            ipString = request.getHeader("Proxy-Client-IP");
        }
        //WL-Proxy-Client-IP是他的weblogic插件加上的头。
        if (StringUtils.isBlank(ipString) || "unknown".equalsIgnoreCase(ipString)) {
            ipString = request.getHeader("WL-Proxy-Client-IP");
        }
        //HTTP_CLIENT_IP :有些代理服务器会加上此请求头。
        if (ipString == null || ipString.length() == 0 || "unknown".equalsIgnoreCase(ipString)) {  
            ipString = request.getHeader("HTTP_CLIENT_IP");  
            System.out.println("HTTP_CLIENT_IP ipString: " + ipString);
        }  
        if (ipString == null || ipString.length() == 0 || "unknown".equalsIgnoreCase(ipString)) {  
            ipString = request.getHeader("HTTP_X_FORWARDED_FOR");  
            System.out.println("HTTP_X_FORWARDED_FOR ipString: " + ipString);
        }  
        //nginx代理一般会加上此请求头。
        if (ipString == null || ipString.length() == 0 || "unknown".equalsIgnoreCase(ipString)) {  
            ipString = request.getHeader("X-Real-IP");  
            System.out.println("X-Real-IP ipString: " + ipString);
        }  
        //当不是上述(代理)方式访问时,request.getRemoteAddr()直接获取客户真实ip
        if (StringUtils.isBlank(ipString) || "unknown".equalsIgnoreCase(ipString)) {
            ipString = request.getRemoteAddr(); //客户端未经过代理,直接访问服务器端(nginx,squid,haproxy);
        }
        // 多个路由时,取第一个非unknown的ip
        final String[] arr = ipString.split(",");
        for (final String str : arr) {
            if (!"unknown".equalsIgnoreCase(str)) {
                ipString = str;
                break;
            }
        }
        return ipString;
    }

    
}
View Code

 

.NET Web 部件 | Web 部件管理器 | Web 部件区

.NET Web 部件 | Web 部件管理器 | Web 部件区

如何解决.NET Web 部件 | Web 部件管理器 | Web 部件区

我在 ASP.NET Web 窗体中使用 Web 部件。我的项目运行正常。 但是,当我拖放 Web 部件管理器时出现此错误,谁能指导我如何在 Windows 10 中解决此问题。

与 sql Server 建立连接时发生与网络相关或特定于实例的错误。服务器未找到或无法访问。验证实例名称是否正确以及 sql Server 是否配置为允许远程连接。 (提供程序:sql 网络接口,错误:26 - 错误定位服务器/指定的实例)

.net 获取客户端外网 ip

.net 获取客户端外网 ip

IPHelper.cs

public class IPHelper
    {
        public static string GetClientIP()
        {
            return GetClientIP(HttpContext.Current);
        }

        public static string GetClientIP(HttpContext context)
        {
            string text = string.Empty;
            text = context.Request.ServerVariables["HTTP_CDN_SRC_IP"];
            if (!string.IsNullOrEmpty(text) && IsIPAddress(text) && !IsInnerIP(text))
            {
                return text;
            }
            text = context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
            if (!string.IsNullOrEmpty(text))
            {
                if (text.IndexOf(".") < -1)
                {
                    text = null;
                }
                else if (text.IndexOf(",") > -1 || text.IndexOf(";") > -1)
                {
                    text = text.Replace(" ", "").Replace("''", "").Replace("\"", "");
                    string[] array = text.Split(",;".ToCharArray());
                    for (int i = 0; i < array.Length; i++)
                    {
                        if (IsIPAddress(array[i]) && !IsInnerIP(array[i]))
                        {
                            return array[i];
                        }
                    }
                }
                else
                {
                    if (IsIPAddress(text) && !IsInnerIP(text))
                    {
                        return text;
                    }
                    text = null;
                }
            }
            if (string.IsNullOrEmpty(text))
            {
                text = context.Request.ServerVariables["REMOTE_ADDR"];
            }
            if (string.IsNullOrEmpty(text))
            {
                text = context.Request.UserHostAddress;
            }
            return text;
        }

        public static bool IsIPAddress(string ipAddress)
        {
            if (string.IsNullOrEmpty(ipAddress))
            {
                return false;
            }
            ipAddress = ipAddress.Trim();
            if (ipAddress.Length < 7 || ipAddress.Length > 15)
            {
                return false;
            }
            string pattern = @"^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$";
            Regex regex = new Regex(pattern, RegexOptions.IgnoreCase);
            return regex.IsMatch(ipAddress);
        }

        public static bool IsInnerIP(String ipAddress)
        {
            bool isInnerIp = false;
            long ipNum = GetIpNum(ipAddress);
            /***** ***** ***** ***** ***** *****
            私有IP:
            A类 10.0.0.0-10.255.255.255
            B类 172.16.0.0-172.31.255.255
            C类 192.168.0.0-192.168.255.255
            还有127.0.0.1这个环回地址 
            ***** ***** ***** ***** ***** *****/
            long aBegin = GetIpNum("10.0.0.0");
            long aEnd = GetIpNum("10.255.255.255");
            long bBegin = GetIpNum("172.16.0.0");
            long bEnd = GetIpNum("172.31.255.255");
            long cBegin = GetIpNum("192.168.0.0");
            long cEnd = GetIpNum("192.168.255.255");
            isInnerIp = IsInner(ipNum, aBegin, aEnd) || IsInner(ipNum, bBegin, bEnd) || IsInner(ipNum, cBegin, cEnd) || ipAddress.Equals("127.0.0.1");
            return isInnerIp;
        }

        private static long GetIpNum(String ipAddress)
        {
            String[] ip = ipAddress.Split(''.'');
            long a = int.Parse(ip[0]);
            long b = int.Parse(ip[1]);
            long c = int.Parse(ip[2]);
            long d = int.Parse(ip[3]);
            long ipNum = a * 256 * 256 * 256 + b * 256 * 256 + c * 256 + d;
            return ipNum;
        }

        private static bool IsInner(long userIp, long begin, long end)
        {
            return (userIp >= begin) && (userIp <= end);
        }
    }

  

Airflow/Pentaho Java 错误 - 启动 mvn 时出错:org.ops4j.pax.web/pax-web-runtime/7.2.10

Airflow/Pentaho Java 错误 - 启动 mvn 时出错:org.ops4j.pax.web/pax-web-runtime/7.2.10

如何解决Airflow/Pentaho Java 错误 - 启动 mvn 时出错:org.ops4j.pax.web/pax-web-runtime/7.2.10

我目前正在使用 Airflow 2.0 使用 BashOperator 来安排我的 Pentaho 作业,如下例所示:

sudo /d/Airflow/pdi-ce-9.1.0.0-324/data-integration/pan.sh -rep:"penta_repo" -user:123 -pass:123 -dir:TEST/RUN_IT -trans:"RUN_IT_1" -level:Basic

当我运行它时,有很多与java库相关的错误。这是日志的一部分:

[...]
[2021-03-04 11:40:49,072] {bash.py:173} INFO - SEVERE: Bundle org.ops4j.pax.web.pax-web-runtime [190] Error starting mvn:org.ops4j.pax.web/pax-web-runtime/7.2.10 (org.osgi.framework.BundleException: Activator start error in bundle org.ops4j.pax.web.pax-web-runtime [190].)
[2021-03-04 11:40:49,072] {bash.py:173} INFO - org.osgi.framework.BundleException: Activator start error in bundle org.ops4j.pax.web.pax-web-runtime [190].
[2021-03-04 11:40:49,072] {bash.py:173} INFO -  at org.apache.Felix.framework.Felix.activateBundle(Felix.java:2290)
[2021-03-04 11:40:49,072] {bash.py:173} INFO -  at org.apache.Felix.framework.Felix.startBundle(Felix.java:2146)
[2021-03-04 11:40:49,072] {bash.py:173} INFO -  at org.apache.Felix.framework.Felix.setActiveStartLevel(Felix.java:1373)
[2021-03-04 11:40:49,072] {bash.py:173} INFO -  at org.apache.Felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308)
[2021-03-04 11:40:49,072] {bash.py:173} INFO -  at java.lang.Thread.run(Thread.java:748)
[2021-03-04 11:40:49,072] {bash.py:173} INFO - Caused by: java.lang.NoClassDefFoundError: org/osgi/service/cm/ConfigurationException
[2021-03-04 11:40:49,072] {bash.py:173} INFO -  at java.lang.class.getDeclaredConstructors0(Native Method)
[2021-03-04 11:40:49,072] {bash.py:173} INFO -  at java.lang.class.privateGetDeclaredConstructors(Class.java:2671)
[2021-03-04 11:40:49,072] {bash.py:173} INFO -  at java.lang.class.getConstructor0(Class.java:3075)
[2021-03-04 11:40:49,072] {bash.py:173} INFO -  at java.lang.class.newInstance(Class.java:412)
[2021-03-04 11:40:49,072] {bash.py:173} INFO -  at org.apache.Felix.framework.Felix.createBundleActivator(Felix.java:4512)
[2021-03-04 11:40:49,072] {bash.py:173} INFO -  at org.apache.Felix.framework.Felix.activateBundle(Felix.java:2221)
[2021-03-04 11:40:49,072] {bash.py:173} INFO -  ... 4 more
[2021-03-04 11:40:49,072] {bash.py:173} INFO - Caused by: java.lang.classNotFoundException: org.osgi.service.cm.ConfigurationException not found by org.ops4j.pax.web.pax-web-runtime [190]
[2021-03-04 11:40:49,072] {bash.py:173} INFO -  at org.apache.Felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1639)
[2021-03-04 11:40:49,072] {bash.py:173} INFO -  at org.apache.Felix.framework.BundleWiringImpl.access$200(BundleWiringImpl.java:80)
[2021-03-04 11:40:49,072] {bash.py:173} INFO -  at org.apache.Felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:2053)
[2021-03-04 11:40:49,072] {bash.py:173} INFO -  at java.lang.classLoader.loadClass(ClassLoader.java:351)
[2021-03-04 11:40:49,072] {bash.py:173} INFO -  ... 10 more
[...]
[2021-03-04 11:43:56,982] {taskinstance.py:1396} ERROR - [Errno 1] Operation not permitted
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/airflow/models/taskinstance.py",line 1086,in _run_raw_task
    self._prepare_and_execute_task_with_callbacks(context,task)
  File "/usr/local/lib/python3.8/dist-packages/airflow/models/taskinstance.py",line 1260,in _prepare_and_execute_task_with_callbacks
    result = self._execute_task(context,task_copy)
  File "/usr/local/lib/python3.8/dist-packages/airflow/models/taskinstance.py",line 1300,in _execute_task
    result = task_copy.execute(context=context)
  File "/usr/local/lib/python3.8/dist-packages/airflow/operators/bash.py",line 171,in execute
    for raw_line in iter(self.sub_process.stdout.readline,b''''):
  File "/usr/local/lib/python3.8/dist-packages/airflow/models/taskinstance.py",line 1215,in signal_handler
    task_copy.on_kill()
  File "/usr/local/lib/python3.8/dist-packages/airflow/operators/bash.py",line 187,in on_kill
    os.killpg(os.getpgid(self.sub_process.pid),signal.SIGTERM)
PermissionError: [Errno 1] Operation not permitted

在这种情况下,有很多java错误并且我的任务没有运行。但是在很多情况下,尽管出现了错误,我的任务仍能成功运行。在这些情况下,bash 命令和 pentaho 执行之间有大约 5 分钟的延迟。下面是另一个成功执行的日志,bash 命令是 09:38AM 但 pentaho 仅在 09:42 AM 执行:

[2021-03-04 09:38:24,482] {bash.py:158} INFO - Running command: sudo /d/Airflow/pdi-ce-9.1.0.0-324/data-integration/pan.sh -rep:"penta_repo" -user:123 -pass:123 -dir:TEST/ALIMENTADOR -trans:"ALIMENTADOR_1" -level:Basic
[2021-03-04 09:38:24,525] {bash.py:169} INFO - Output:
[2021-03-04 09:38:28,739] {bash.py:173} INFO - 12:38:28,739 INFO  [KarafBoot] Checking to see if org.pentaho.clean.karaf.cache is enabled
[2021-03-04 09:38:32,001] {bash.py:173} INFO - 12:38:32,001 INFO  [KarafInstance]
[2021-03-04 09:38:32,001] {bash.py:173} INFO - *******************************************************************************
[2021-03-04 09:38:32,001] {bash.py:173} INFO - *** Karaf Instance Number: 68 at /d/Airflow/pdi-ce-9.1.0.0-324/data-integra ***
[2021-03-04 09:38:32,001] {bash.py:173} INFO - ***   tion/./system/karaf/caches/pan/data-1                                 ***
[2021-03-04 09:38:32,001] {bash.py:173} INFO - *** Karaf Port:8869                                                         ***
[2021-03-04 09:38:32,001] {bash.py:173} INFO - *** Osgi Service Port:9118                                                  ***
[2021-03-04 09:38:32,001] {bash.py:173} INFO - *******************************************************************************
[...]
[2021-03-04 09:38:36,773] {bash.py:173} INFO - 2021-03-04 12:38:36.770:INFO::FelixStartLevel: Logging initialized @11384ms to org.eclipse.jetty.util.log.StdErrLog
[2021-03-04 09:38:36,781] {bash.py:173} INFO - Mar 04,2021 12:38:36 PM org.apache.karaf.main.Main$1 log
[2021-03-04 09:38:36,782] {bash.py:173} INFO - SEVERE: Bundle org.ops4j.pax.web.pax-web-runtime [190] Error starting mvn:org.ops4j.pax.web/pax-web-runtime/7.2.10 (org.osgi.framework.BundleException: Activator start error in bundle org.ops4j.pax.web.pax-web-runtime [190].)
[2021-03-04 09:38:36,782] {bash.py:173} INFO - org.osgi.framework.BundleException: Activator start error in bundle org.ops4j.pax.web.pax-web-runtime [190].
[2021-03-04 09:38:36,782] {bash.py:173} INFO -  at org.apache.Felix.framework.Felix.activateBundle(Felix.java:2290)
[2021-03-04 09:38:36,782] {bash.py:173} INFO -  at org.apache.Felix.framework.Felix.startBundle(Felix.java:2146)
[2021-03-04 09:38:36,782] {bash.py:173} INFO -  at org.apache.Felix.framework.Felix.setActiveStartLevel(Felix.java:1373)
[2021-03-04 09:38:36,782] {bash.py:173} INFO -  at org.apache.Felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308)
[2021-03-04 09:38:36,782] {bash.py:173} INFO -  at java.lang.Thread.run(Thread.java:748)
[2021-03-04 09:38:36,782] {bash.py:173} INFO - Caused by: java.lang.NoClassDefFoundError: org/osgi/service/cm/ConfigurationException
[2021-03-04 09:38:36,782] {bash.py:173} INFO -  at java.lang.class.getDeclaredConstructors0(Native Method)
[2021-03-04 09:38:36,782] {bash.py:173} INFO -  at java.lang.class.privateGetDeclaredConstructors(Class.java:2671)
[2021-03-04 09:38:36,782] {bash.py:173} INFO -  at java.lang.class.getConstructor0(Class.java:3075)
[2021-03-04 09:38:36,782] {bash.py:173} INFO -  at java.lang.class.newInstance(Class.java:412)
[2021-03-04 09:38:36,782] {bash.py:173} INFO -  at org.apache.Felix.framework.Felix.createBundleActivator(Felix.java:4512)
[2021-03-04 09:38:36,782] {bash.py:173} INFO -  at org.apache.Felix.framework.Felix.activateBundle(Felix.java:2221)
[2021-03-04 09:38:36,782] {bash.py:173} INFO -  ... 4 more
[2021-03-04 09:38:36,782] {bash.py:173} INFO - Caused by: java.lang.classNotFoundException: org.osgi.service.cm.ConfigurationException not found by org.ops4j.pax.web.pax-web-runtime [190]
[2021-03-04 09:38:36,782] {bash.py:173} INFO -  at org.apache.Felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1639)
[2021-03-04 09:38:36,783] {bash.py:173} INFO -  at org.apache.Felix.framework.BundleWiringImpl.access$200(BundleWiringImpl.java:80)
[2021-03-04 09:38:36,783] {bash.py:173} INFO -  at org.apache.Felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:2053)
[2021-03-04 09:38:36,783] {bash.py:173} INFO -  at java.lang.classLoader.loadClass(ClassLoader.java:351)
[2021-03-04 09:38:36,783] {bash.py:173} INFO -  ... 10 more
[...]
[2021-03-04 09:42:37,209] {bash.py:173} INFO -  at org.pentaho.di.osgi.KarafLifecycleListener.waitForFeatures(KarafLifecycleListener.java:204)
[2021-03-04 09:42:37,209] {bash.py:173} INFO -  at org.pentaho.di.osgi.KarafLifecycleListener.waitForBundlesstarted(KarafLifecycleListener.java:177)
[2021-03-04 09:42:37,209] {bash.py:173} INFO -  at org.pentaho.di.osgi.KarafLifecycleListener.lambda$maybeStartWatchers$0(KarafLifecycleListener.java:160)
[2021-03-04 09:42:37,209] {bash.py:173} INFO -  at java.lang.Thread.run(Thread.java:748)
[2021-03-04 09:42:37,209] {bash.py:173} INFO - 12:42:37,208 INFO  [DriverManager] Finished installing drivers kars.
[2021-03-04 09:42:37,223] {bash.py:173} INFO - 2021/03/04 12:42:37 - Logging is at level : Basic
[2021-03-04 09:42:37,229] {bash.py:173} INFO - 2021/03/04 12:42:37 - Start of run.
[2021-03-04 09:42:37,243] {bash.py:173} INFO - 2021/03/04 12:42:37 - RepositoriesMeta - Reading repositories XML file: /d/Airflow/pdi-ce-9.1.0.0-324/data-integration/repositories.xml
[2021-03-04 09:42:39,936] {bash.py:173} INFO - 2021/03/04 12:42:39 - ALIMENTADOR_1 - dispatching started for transformation [ALIMENTADOR_1]
[2021-03-04 09:42:40,354] {bash.py:173} INFO - 2021/03/04 12:42:40 - BDN_STAGE_ST5P_ALIMENTADOR.0 - Connected to database [BDN_DCC] (commit=10000)
[2021-03-04 09:42:40,733] {bash.py:173} INFO - 2021/03/04 12:42:40 - OPER_ALIMENTADOR.0 - Finished reading query,closing connection.
[2021-03-04 09:42:40,740] {bash.py:173} INFO - 2021/03/04 12:42:40 - OPER_ALIMENTADOR.0 - Finished processing (I=1630,O=0,R=0,W=1630,U=0,E=0)
[2021-03-04 09:42:40,804] {bash.py:173} INFO - 2021/03/04 12:42:40 - BDN_STAGE_ST5P_ALIMENTADOR.0 - Finished processing (I=0,O=1630,R=1630,812] {bash.py:173} INFO - 2021/03/04 12:42:40 - Finished!
[2021-03-04 09:42:40,812] {bash.py:173} INFO - 2021/03/04 12:42:40 - Start=2021/03/04 12:42:39.933,Stop=2021/03/04 12:42:40.812
[2021-03-04 09:42:40,813] {bash.py:173} INFO - 2021/03/04 12:42:40 - Processing ended after 0 seconds.
[2021-03-04 09:42:40,813] {bash.py:173} INFO - 2021/03/04 12:42:40 - ALIMENTADOR_1 -
[2021-03-04 09:42:40,813] {bash.py:173} INFO - 2021/03/04 12:42:40 - ALIMENTADOR_1 - Step OPER_ALIMENTADOR.0 ended successfully,processed 1630 lines. ( - lines/s)
[2021-03-04 09:42:40,813] {bash.py:173} INFO - 2021/03/04 12:42:40 - ALIMENTADOR_1 - Step BDN_STAGE_ST5P_ALIMENTADOR.0 ended successfully,processed 1630 lines. ( - lines/s)
[2021-03-04 09:42:41,403] {bash.py:177} INFO - Command exited with return code 0
[2021-03-04 09:42:41,768] {taskinstance.py:1135} INFO - Marking task as SUCCESS. dag_id=ALIMENTADOR_JOB,task_id=Alimentador,execution_date=20210304T110100,start_date=20210304T123823,end_date=20210304T124241
[2021-03-04 09:42:41,865] {taskinstance.py:1195} INFO - 1 downstream tasks scheduled from follow-on schedule check
[2021-03-04 09:42:41,881] {local_task_job.py:118} INFO - Task exited with return code 0

我的问题是:

  1. 如何修复这些 Java 错误?
  2. 这些 java 错误是否与我成功运行时的延迟有关?

非常感谢!

asp.net-web-api – System.Web.Routing.RouteCollection不包含“MapHttpRoute”的定义 – VS 2012,Web API

asp.net-web-api – System.Web.Routing.RouteCollection不包含“MapHttpRoute”的定义 – VS 2012,Web API

我刚刚安装了Visual Studio 2012,并开始检查MVC 4和Web Api。
我已经用Web API创建了一个新的MVC 4应用程序。基于一些示例和教程,我开始配置我的路由:
routes.MapHttpRoute(
                name: "Controller only",routeTemplate: "api/{controller}"
            );

但是,这会导致RouteCollection不包含MapHttpRoute的定义的错误。我是否安装了一些DLL?
据我看到,我已经安装了所有正确的DLL和版本。

解决方法

我已经通过在RouteConfig.cs中添加对System.Web.Http的引用来解决它

我们今天的关于java web 获取客户端外网 ip 和所在区域java获取外网ip地址的分享就到这里,谢谢您的阅读,如果想了解更多关于.NET Web 部件 | Web 部件管理器 | Web 部件区、.net 获取客户端外网 ip、Airflow/Pentaho Java 错误 - 启动 mvn 时出错:org.ops4j.pax.web/pax-web-runtime/7.2.10、asp.net-web-api – System.Web.Routing.RouteCollection不包含“MapHttpRoute”的定义 – VS 2012,Web API的相关信息,可以在本站进行搜索。

本文标签: