<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Spring-boot | SDT 攻城獅區</title>
	<atom:link href="https://sdt.hameba.tw/tag/spring-boot/feed/" rel="self" type="application/rss+xml" />
	<link>https://sdt.hameba.tw</link>
	<description>由Steven, Der, Ted 三位高級打字員所組成，是三位工程師(攻城獅)所維護的技術分享平台，或許偶爾會分享一些日常，有任何問題或是錯誤的部分，歡迎留言告訴我們！</description>
	<lastBuildDate>Thu, 27 Feb 2020 16:30:44 +0800</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.3</generator>

<image>
	<url>https://sdt.hameba.tw/wp-content/uploads/2020/02/hameba_favicon-150x150.png</url>
	<title>Spring-boot | SDT 攻城獅區</title>
	<link>https://sdt.hameba.tw</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>JAVA取得本機實際IP位置</title>
		<link>https://sdt.hameba.tw/559/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=java%25e5%258f%2596%25e5%25be%2597%25e6%259c%25ac%25e6%25a9%259f%25e5%25af%25a6%25e9%259a%259bip%25e4%25bd%258d%25e7%25bd%25ae</link>
				<comments>https://sdt.hameba.tw/559/#respond</comments>
				<pubDate>Thu, 27 Feb 2020 16:28:15 +0000</pubDate>
		<dc:creator><![CDATA[Hsu Steven]]></dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[IP]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Spring-boot]]></category>

		<guid isPermaLink="false">https://sdt.hameba.tw/?p=559</guid>
				<description><![CDATA[<p>先明確了解一些規則： 127.xxx.xxx.xxx 屬於&#8221;loopback&#8221; 地址， &#8230; </p>
<p class="link-more"><a href="https://sdt.hameba.tw/559/" class="more-link">閱讀全文<span class="screen-reader-text">〈JAVA取得本機實際IP位置〉</span></a></p>
The post <a href="https://sdt.hameba.tw/559/">JAVA取得本機實際IP位置</a> first appeared on <a href="https://sdt.hameba.tw">SDT 攻城獅區</a>.]]></description>
								<content:encoded><![CDATA[<p>先明確了解一些規則：</p>
<p>127.xxx.xxx.xxx 屬於&#8221;loopback&#8221; 地址，即只能你自己的本機可見，就是本機地址，比較常見的有127.0.0.1；</p>
<p><span id="more-559"></span><br />
192.168.xxx.xxx 屬於private 私有地址(site local address)，屬於本地組織內部訪問，只能在本地局域網可見。</p>
<p>同樣10.xxx.xxx.xxx、從172.16.xxx.xxx 到 172.31.xxx.xxx都是私有地址，也是屬於組織內部訪問；</p>
<p>169.254.xxx.xxx 屬於連接本地地址（link local IP），在單獨網段可用<br />
從224.xxx.xxx.xxx 到 239.xxx.xxx.xxx 屬於組播地址<br />
比較特殊的255.255.255.255 屬於廣播地址<br />
除此之外的地址就是點對點的可用的公開IPv4地址</p>
<p>本機實際IP位置的正確方式，可以參考以下，測試得到路由所配發的ip</p><pre class="crayon-plain-tag">package ipTest;

import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.util.Enumeration;

public class Test {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        InetAddress ip;
        try {
            // 正确的IP拿法
            System.out.println("get LocalHost LAN Address : " + getLocalHostLANAddress().getHostAddress());


        } catch (UnknownHostException e) {

            e.printStackTrace();

        }
    }

    // 正确的IP拿法，即优先拿site-local地址
    private static InetAddress getLocalHostLANAddress() throws UnknownHostException {
        try {
            InetAddress candidateAddress = null;
            // 遍历所有的网络接口
            for (Enumeration ifaces = NetworkInterface.getNetworkInterfaces(); ifaces.hasMoreElements();) {
                NetworkInterface iface = (NetworkInterface) ifaces.nextElement();
                // 在所有的接口下再遍历IP
                for (Enumeration inetAddrs = iface.getInetAddresses(); inetAddrs.hasMoreElements();) {
                    InetAddress inetAddr = (InetAddress) inetAddrs.nextElement();
                    if (!inetAddr.isLoopbackAddress()) {// 排除loopback类型地址
                        if (inetAddr.isSiteLocalAddress()) {
                            // 如果是site-local地址，就是它了
                            return inetAddr;
                        } else if (candidateAddress == null) {
                            // site-local类型的地址未被发现，先记录候选地址
                            candidateAddress = inetAddr;
                        }
                    }
                }
            }
            if (candidateAddress != null) {
                return candidateAddress;
            }
            // 如果没有发现 non-loopback地址.只能用最次选的方案
            InetAddress jdkSuppliedAddress = InetAddress.getLocalHost();
            if (jdkSuppliedAddress == null) {
                throw new UnknownHostException("The JDK InetAddress.getLocalHost() method unexpectedly returned null.");
            }
            return jdkSuppliedAddress;
        } catch (Exception e) {
            UnknownHostException unknownHostException = new UnknownHostException(
                    "Failed to determine LAN address: " + e);
            unknownHostException.initCause(e);
            throw unknownHostException;
        }
    }


}</pre><p>&nbsp;</p>
<p>Reference</p>
<p><a href="https://www.cnblogs.com/starcrm/p/7071227.html" target="_blank" rel="noopener noreferrer">https://www.cnblogs.com/starcrm/p/7071227.html</a></p>The post <a href="https://sdt.hameba.tw/559/">JAVA取得本機實際IP位置</a> first appeared on <a href="https://sdt.hameba.tw">SDT 攻城獅區</a>.]]></content:encoded>
							<wfw:commentRss>https://sdt.hameba.tw/559/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
							</item>
		<item>
		<title>VS Code 安裝 Java spring boot 環境</title>
		<link>https://sdt.hameba.tw/535/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=vs-code-%25e5%25ae%2589%25e8%25a3%259d-java-spring-boot-%25e7%2592%25b0%25e5%25a2%2583</link>
				<comments>https://sdt.hameba.tw/535/#respond</comments>
				<pubDate>Sat, 22 Feb 2020 15:32:34 +0000</pubDate>
		<dc:creator><![CDATA[Hsu Steven]]></dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Gradle]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[Spring-boot]]></category>
		<category><![CDATA[VS Code]]></category>

		<guid isPermaLink="false">https://sdt.hameba.tw/?p=535</guid>
				<description><![CDATA[<p>以往開發Java環境都會選用eclipse， 但我比較喜歡VS code的IDE開發工具， 所以找一下發現原來 &#8230; </p>
<p class="link-more"><a href="https://sdt.hameba.tw/535/" class="more-link">閱讀全文<span class="screen-reader-text">〈VS Code 安裝 Java spring boot 環境〉</span></a></p>
The post <a href="https://sdt.hameba.tw/535/">VS Code 安裝 Java spring boot 環境</a> first appeared on <a href="https://sdt.hameba.tw">SDT 攻城獅區</a>.]]></description>
								<content:encoded><![CDATA[<p>以往開發Java環境都會選用eclipse，</p>
<p>但我比較喜歡VS code的IDE開發工具，</p>
<p><span id="more-535"></span>所以找一下發現原來微軟也有把Java開發環境導入VS code，</p>
<p>以下是我MAC快速配置，</p>
<p>進入plugin 搜尋  <a href="https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-pack" target="_blank" rel="nofollow noopener noreferrer">Java Extension Pack</a>、<a href="https://marketplace.visualstudio.com/items?itemName=Pivotal.vscode-boot-dev-pack">Spring Boot Extension Pack</a>，</p>
<p>選擇安裝後，VS code開啟Java spring專案就會自動掃專案的內容，</p>
<p>這邊我就沒有特別設定, 引入jar資源，</p>
<p>假設有特別引入IBM or EAR資源的話，可以在專案.vscdoe/settings.json設定。</p>
<p>&nbsp;</p>
<p>Reference</p>
<p><a href="https://zhuanlan.zhihu.com/p/54358113" target="_blank" rel="noopener noreferrer">https://zhuanlan.zhihu.com/p/54358113</a></p>The post <a href="https://sdt.hameba.tw/535/">VS Code 安裝 Java spring boot 環境</a> first appeared on <a href="https://sdt.hameba.tw">SDT 攻城獅區</a>.]]></content:encoded>
							<wfw:commentRss>https://sdt.hameba.tw/535/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
							</item>
	</channel>
</rss>
