<?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>IntelliJ IDEA &#8211; My Shitty Code</title>
	<atom:link href="https://myshittycode.com/tag/intellij-idea/feed/" rel="self" type="application/rss+xml" />
	<link>https://myshittycode.com</link>
	<description>Embracing the Messiness in Search of Epic Solutions</description>
	<lastBuildDate>Fri, 06 Jan 2023 16:44:29 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>

<image>
	<url>https://myshittycode.com/wp-content/uploads/2022/04/cropped-icon-32x32.png</url>
	<title>IntelliJ IDEA &#8211; My Shitty Code</title>
	<link>https://myshittycode.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">205304208</site>	<item>
		<title>GCP: Pushing Codebase from IntelliJ IDEA to VM Instance</title>
		<link>https://myshittycode.com/2022/02/08/gcp-pushing-codebase-from-intellij-idea-to-vm-instance/</link>
					<comments>https://myshittycode.com/2022/02/08/gcp-pushing-codebase-from-intellij-idea-to-vm-instance/#respond</comments>
		
		<dc:creator><![CDATA[Shitty Author]]></dc:creator>
		<pubDate>Wed, 09 Feb 2022 01:14:01 +0000</pubDate>
				<category><![CDATA[Development Tools]]></category>
		<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Google Cloud Platform]]></category>
		<category><![CDATA[IDE]]></category>
		<category><![CDATA[IntelliJ IDEA]]></category>
		<category><![CDATA[SSH]]></category>
		<guid isPermaLink="false">https://myshittycode.com/?p=1267</guid>

					<description><![CDATA[<p>OBJECTIVE To push codebase from IntelliJ IDEA (or any JetBrains products) on a local machine to a VM instance in Google Cloud Platform. To run the codebase remotely. WHY DO THIS You want to leverage all the power of a modern IDE on your 4K screen. You do not want to use remote desktop tools [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://myshittycode.com/2022/02/08/gcp-pushing-codebase-from-intellij-idea-to-vm-instance/">GCP: Pushing Codebase from IntelliJ IDEA to VM Instance</a> appeared first on <a rel="nofollow" href="https://myshittycode.com">My Shitty Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading" id="objective">OBJECTIVE</h2>



<p>To push codebase from IntelliJ IDEA (or any JetBrains products) on a local machine to a VM instance in Google Cloud Platform.</p>



<p>To run the codebase remotely.</p>



<h2 class="wp-block-heading" id="why-do-this">WHY DO THIS</h2>



<p>You want to leverage all the power of a modern IDE on your 4K screen.</p>



<p>You do not want to use remote desktop tools such as VNC or NoMachine due to performance and screen lag problems.</p>



<p>Your team members make fun of your VIM skills.</p>



<h2 class="wp-block-heading" id="solution">SOLUTION</h2>



<h3 class="wp-block-heading" id="configuring-vm-port-forwarding">Configuring VM Port Forwarding</h3>



<p>Log into GCP.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
gcloud auth login
</pre></div>


<p>Perform port forwarding over SSH using your running VM.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
# SYNTAX
gcloud compute ssh VM_NAME \
    --project PROJECT_ID \
    --zone ZONE \
    -- -NL LOCAL_PORT:localhost:REMOTE_PORT

# EXAMPLE
gcloud compute ssh shitty_vm \
    --project shitty_project \
    --zone us-central1-b \
    -- -NL 8888:localhost:22
</pre></div>


<p>Note: If you choose to listen to local port 22, you will most likely to get this error because your local SSH server may already be using it:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
bind: Address already in use
channel_setup_fwd_listener: cannot listen to port: 22
Could not request local forwarding.
</pre></div>


<p>If this is your first SSH into your VM, you will be prompted to create the SSH key pair. In this case, keep pressing the &#8220;Enter&#8221; key until it is created.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
WARNING: The private SSH key file for gcloud does not exist.
WARNING: The public SSH key file for gcloud does not exist.
WARNING: You do not have an SSH key for gcloud.
WARNING: SSH keygen will be executed to generate a key.
Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/shitty_user/.ssh/google_compute_engine.
Your public key has been saved in /Users/shitty_user/.ssh/google_compute_engine.pub.
The key fingerprint is:
SHA256:gmwGL9bfJLi/FYnebZLL0vVBYoZ3XeT/ivSSFCmiRT8 shitty_user@shitty_machine
The key&#039;s randomart image is:
+---&#x5B;RSA 3072]----+
|               ..|
|        .      ..|
|  .    . o   o ..|
|   = o .+.E = . .|
|  o O +oS= * .  .|
| . + +.* +. o   .|
|    . o.*.oo.o  .|
|     ..o.+ .+o . |
|      ooo   ..o  |
+----&#x5B;SHA256]-----+
External IP address was not found; defaulting to using IAP tunneling.
Writing 3 keys to /Users/shitty_user/.ssh/google_compute_known_hosts
</pre></div>


<p>Upon a successful port forwarding, the command will hang with the following text:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
External IP address was not found; defaulting to using IAP tunneling.
Existing host keys found in /Users/shitty_user/.ssh/google_compute_known_hosts
</pre></div>


<p>That is an expected behavior because the SSH tunnel is now established between your local machine and the VM.</p>



<h3 class="wp-block-heading" id="configuring-intellij-idea">Configuring IntelliJ IDEA</h3>



<p>In IntelliJ IDEA, select <strong>Tools</strong> &gt; <strong>Deployment</strong> &gt; <strong>Browser Remote Host</strong></p>



<p>Under <strong>Remote Host</strong> panel, select <strong>…</strong> button.</p>



<figure class="wp-block-image size-large"><a href="https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_4_41_31_pm-1.png?x45560"><img fetchpriority="high" decoding="async" width="2362" height="492" src="https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_4_41_31_pm-1.png?x45560" alt="" class="wp-image-1283" srcset="https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_4_41_31_pm-1.png 2362w, https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_4_41_31_pm-1-300x62.png 300w, https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_4_41_31_pm-1-1024x213.png 1024w, https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_4_41_31_pm-1-768x160.png 768w, https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_4_41_31_pm-1-1536x320.png 1536w, https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_4_41_31_pm-1-2048x427.png 2048w" sizes="(max-width: 2362px) 100vw, 2362px" /></a></figure>



<p>Under <strong>Add Server</strong> dialog:</p>



<ul class="wp-block-list">
<li><strong>Name:</strong> <em>&lt;A Memorable Name&#8230; ex: shitty_server&gt;</em></li>



<li><strong>Type:</strong> SFTP</li>
</ul>



<p>Click <strong>OK</strong> button.</p>



<figure class="wp-block-image aligncenter size-large is-resized"><a href="https://myshittycode.com/wp-content/uploads/2022/02/screen-shot-2022-02-08-at-4.42.48-pm-1.png?x45560"><img decoding="async" src="https://myshittycode.com/wp-content/uploads/2022/02/screen-shot-2022-02-08-at-4.42.48-pm-1.png?x45560" alt="" class="wp-image-1285" width="511" height="256" srcset="https://myshittycode.com/wp-content/uploads/2022/02/screen-shot-2022-02-08-at-4.42.48-pm-1.png 1234w, https://myshittycode.com/wp-content/uploads/2022/02/screen-shot-2022-02-08-at-4.42.48-pm-1-300x150.png 300w, https://myshittycode.com/wp-content/uploads/2022/02/screen-shot-2022-02-08-at-4.42.48-pm-1-1024x513.png 1024w, https://myshittycode.com/wp-content/uploads/2022/02/screen-shot-2022-02-08-at-4.42.48-pm-1-768x385.png 768w" sizes="(max-width: 511px) 100vw, 511px" /></a></figure>



<p>Under <strong>Deployment</strong> dialog, select <strong>…</strong> button on <strong>SSH Configurations</strong>.</p>



<figure class="wp-block-image size-large"><a href="https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_4_45_13_pm-1.png?x45560"><img decoding="async" width="1772" height="1268" src="https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_4_45_13_pm-1.png?x45560" alt="" class="wp-image-1287" srcset="https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_4_45_13_pm-1.png 1772w, https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_4_45_13_pm-1-300x215.png 300w, https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_4_45_13_pm-1-1024x733.png 1024w, https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_4_45_13_pm-1-768x550.png 768w, https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_4_45_13_pm-1-1536x1099.png 1536w" sizes="(max-width: 1772px) 100vw, 1772px" /></a></figure>



<p>Under <strong>SSH Configurations</strong> dialog:</p>



<ul class="wp-block-list">
<li><strong>Host:</strong> localhost</li>



<li><strong>Port:</strong> 8888 <em>(or the local port you specified)</em></li>



<li><strong>User name:</strong> <em>&lt;Your VM&#8217;s user name&gt;</em></li>



<li><strong>Authentication type:</strong> Key pair</li>



<li><strong>Private key file:</strong> /<em>&lt;PATH&gt;</em>/.ssh/google_compute_engine</li>
</ul>



<p>Click on <strong>Test Connection</strong> button and ensure it is successful.</p>



<p>Click <strong>OK</strong> button.</p>



<figure class="wp-block-image size-large"><a href="https://myshittycode.com/wp-content/uploads/2022/02/screen-shot-2022-02-08-at-4.50.39-pm-1.png?x45560"><img loading="lazy" decoding="async" width="1956" height="1460" src="https://myshittycode.com/wp-content/uploads/2022/02/screen-shot-2022-02-08-at-4.50.39-pm-1.png?x45560" alt="" class="wp-image-1289" srcset="https://myshittycode.com/wp-content/uploads/2022/02/screen-shot-2022-02-08-at-4.50.39-pm-1.png 1956w, https://myshittycode.com/wp-content/uploads/2022/02/screen-shot-2022-02-08-at-4.50.39-pm-1-300x224.png 300w, https://myshittycode.com/wp-content/uploads/2022/02/screen-shot-2022-02-08-at-4.50.39-pm-1-1024x764.png 1024w, https://myshittycode.com/wp-content/uploads/2022/02/screen-shot-2022-02-08-at-4.50.39-pm-1-768x573.png 768w, https://myshittycode.com/wp-content/uploads/2022/02/screen-shot-2022-02-08-at-4.50.39-pm-1-1536x1147.png 1536w" sizes="auto, (max-width: 1956px) 100vw, 1956px" /></a></figure>



<p>Under <strong>Deployment</strong> dialog, select <strong>Mappings</strong> tab.</p>



<figure class="wp-block-image size-large"><a href="https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_4_55_02_pm-1.png?x45560"><img loading="lazy" decoding="async" width="1772" height="1268" src="https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_4_55_02_pm-1.png?x45560" alt="" class="wp-image-1291" srcset="https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_4_55_02_pm-1.png 1772w, https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_4_55_02_pm-1-300x215.png 300w, https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_4_55_02_pm-1-1024x733.png 1024w, https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_4_55_02_pm-1-768x550.png 768w, https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_4_55_02_pm-1-1536x1099.png 1536w" sizes="auto, (max-width: 1772px) 100vw, 1772px" /></a></figure>



<p>Under <strong>Mapping</strong>s tab, click on the folder icon and specify a location to deploy the codebase to.</p>



<figure class="wp-block-image size-large is-resized"><a href="https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_4_55_03_pm-2-1.png?x45560"><img loading="lazy" decoding="async" src="https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_4_55_03_pm-2-1.png?x45560" alt="" class="wp-image-1294" width="770" height="550" srcset="https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_4_55_03_pm-2-1.png 1772w, https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_4_55_03_pm-2-1-300x215.png 300w, https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_4_55_03_pm-2-1-1024x733.png 1024w, https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_4_55_03_pm-2-1-768x550.png 768w, https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_4_55_03_pm-2-1-1536x1099.png 1536w" sizes="auto, (max-width: 770px) 100vw, 770px" /></a></figure>



<p>Click <strong>OK</strong> button.</p>



<p>Under <strong>Remote Host</strong> panel, you can now browse and access the files in your VM remotely.</p>



<figure class="wp-block-image size-large"><a href="https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_5_02_35_pm-1.png?x45560"><img loading="lazy" decoding="async" width="2560" height="1945" src="https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_5_02_35_pm-1.png?x45560" alt="" class="wp-image-1296" srcset="https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_5_02_35_pm-1.png 2560w, https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_5_02_35_pm-1-300x228.png 300w, https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_5_02_35_pm-1-1024x778.png 1024w, https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_5_02_35_pm-1-768x583.png 768w, https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_5_02_35_pm-1-1536x1167.png 1536w, https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_5_02_35_pm-1-2048x1556.png 2048w" sizes="auto, (max-width: 2560px) 100vw, 2560px" /></a></figure>



<h3 class="wp-block-heading" id="pushing-codebase-from-intellij-idea-to-vm">Pushing Codebase from IntelliJ IDEA to VM</h3>



<p>To deploy codebase to the VM, right click on the directory, select <strong>Deployment</strong> &gt; <strong>Upload to [VM_NAME]</strong>.</p>



<figure class="wp-block-image size-large"><a href="https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_5_04_51_pm-1.png?x45560"><img loading="lazy" decoding="async" width="1530" height="1406" src="https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_5_04_51_pm-1.png?x45560" alt="" class="wp-image-1298" srcset="https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_5_04_51_pm-1.png 1530w, https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_5_04_51_pm-1-300x276.png 300w, https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_5_04_51_pm-1-1024x941.png 1024w, https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_5_04_51_pm-1-768x706.png 768w" sizes="auto, (max-width: 1530px) 100vw, 1530px" /></a></figure>



<p>The codebase should be copied to the location you specified.</p>



<figure class="wp-block-image aligncenter size-large is-resized"><a href="https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_5_06_17_pm-1.png?x45560"><img loading="lazy" decoding="async" src="https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_5_06_17_pm-1.png?x45560" alt="" class="wp-image-1300" width="349" height="512" srcset="https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_5_06_17_pm-1.png 770w, https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_5_06_17_pm-1-204x300.png 204w, https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_5_06_17_pm-1-697x1024.png 697w, https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_5_06_17_pm-1-768x1129.png 768w" sizes="auto, (max-width: 349px) 100vw, 349px" /></a></figure>



<p>Tips: If you makes changes in both your local machine and VM, select <strong>Deployment</strong> &gt; <strong>Sync with Deployed to [VM_NAME]</strong>. This allows you to synchronize the changes on both sides.</p>



<h3 class="wp-block-heading" id="running-codebase-remotely">Running Codebase Remotely</h3>



<p>To run the codebase remotely, select <strong>Tools</strong> &gt; <strong>Start SSH Session</strong>.</p>



<figure class="wp-block-image size-large"><a href="https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_7_19_22_pm-1.png?x45560"><img loading="lazy" decoding="async" width="1790" height="722" src="https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_7_19_22_pm-1.png?x45560" alt="" class="wp-image-1311" srcset="https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_7_19_22_pm-1.png 1790w, https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_7_19_22_pm-1-300x121.png 300w, https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_7_19_22_pm-1-1024x413.png 1024w, https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_7_19_22_pm-1-768x310.png 768w, https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_7_19_22_pm-1-1536x620.png 1536w" sizes="auto, (max-width: 1790px) 100vw, 1790px" /></a></figure>



<p>Select the configured host.</p>



<figure class="wp-block-image aligncenter size-large is-resized"><a href="https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_7_19_38_pm.png?x45560"><img loading="lazy" decoding="async" src="https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_7_19_38_pm.png?x45560" alt="" class="wp-image-1313" width="376" height="114"/></a></figure>



<p>Run the codebase.</p>



<figure class="wp-block-image size-large"><a href="https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_7_25_29_pm.png?x45560"><img loading="lazy" decoding="async" width="2190" height="1712" src="https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_7_25_29_pm.png?x45560" alt="" class="wp-image-1315" srcset="https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_7_25_29_pm.png 2190w, https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_7_25_29_pm-300x235.png 300w, https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_7_25_29_pm-1024x800.png 1024w, https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_7_25_29_pm-768x600.png 768w, https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_7_25_29_pm-1536x1201.png 1536w, https://myshittycode.com/wp-content/uploads/2022/02/screen_shot_2022-02-08_at_7_25_29_pm-2048x1601.png 2048w" sizes="auto, (max-width: 2190px) 100vw, 2190px" /></a></figure>
<p>The post <a rel="nofollow" href="https://myshittycode.com/2022/02/08/gcp-pushing-codebase-from-intellij-idea-to-vm-instance/">GCP: Pushing Codebase from IntelliJ IDEA to VM Instance</a> appeared first on <a rel="nofollow" href="https://myshittycode.com">My Shitty Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://myshittycode.com/2022/02/08/gcp-pushing-codebase-from-intellij-idea-to-vm-instance/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1267</post-id>	</item>
		<item>
		<title>Spring Boot: Restarting App using Dev Tools with IntelliJ IDEA</title>
		<link>https://myshittycode.com/2019/04/26/spring-boot-restarting-app-using-dev-tools-in-intellij-idea/</link>
					<comments>https://myshittycode.com/2019/04/26/spring-boot-restarting-app-using-dev-tools-in-intellij-idea/#respond</comments>
		
		<dc:creator><![CDATA[Shitty Author]]></dc:creator>
		<pubDate>Fri, 26 Apr 2019 17:47:44 +0000</pubDate>
				<category><![CDATA[Development Tools]]></category>
		<category><![CDATA[IntelliJ IDEA]]></category>
		<category><![CDATA[Spring Boot]]></category>
		<guid isPermaLink="false">http://myshittycode.com/?p=1096</guid>

					<description><![CDATA[<p>Spring Boot provides spring-boot-devtools module that allows the app to &#8220;smartly&#8221; restart whenever the files on the classpath have changed. Because the rarely changed classes (ex: 3rd party JARs) are separated out into a different classloader from the app&#8217;s actively developed classes&#8217; classloader, it allows Spring Boot to quickly restart the app compared to &#8220;cold [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://myshittycode.com/2019/04/26/spring-boot-restarting-app-using-dev-tools-in-intellij-idea/">Spring Boot: Restarting App using Dev Tools with IntelliJ IDEA</a> appeared first on <a rel="nofollow" href="https://myshittycode.com">My Shitty Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Spring Boot provides <b>spring-boot-devtools</b> module that allows the app to &#8220;smartly&#8221; restart whenever the files on the classpath have changed.</p>



<p>Because the rarely changed classes (ex: 3rd party JARs) are separated out into a different classloader from the app&#8217;s actively developed classes&#8217; classloader, it allows Spring Boot to quickly restart the app compared to &#8220;cold start&#8221;.</p>



<h2 class="wp-block-heading">DEPENDENCY</h2>



<p>First, add the following dependency:-</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: xml; title: ; notranslate">
&lt;dependency&gt;
	&lt;groupid&gt;org.springframework.boot&lt;/groupid&gt;
	&lt;artifactid&gt;spring-boot-devtools&lt;/artifactid&gt;
	&lt;scope&gt;runtime&lt;/scope&gt;
&lt;/dependency&gt;
</pre></div>


<h2 class="wp-block-heading">CONFIGURING INTELLIJ IDEA</h2>



<p>In IntelliJ IDEA:-</p>



<ul class="wp-block-list">
<li>Click <b>SHIFT</b> twice to bring up the &#8220;Search History&#8221; dialog.</li>



<li>Select &#8220;Actions&#8221; tab.</li>



<li>Type &#8220;Registry&#8221; in the search box.</li>



<li>Select &#8220;Registry&#8230;&#8221;.</li>
</ul>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="1446" height="544" src="https://myshittycode.com/wp-content/uploads/2019/04/screen_shot_2019-04-26_at_12_22_30_pm-1.png?x45560" alt="" class="wp-image-1097" srcset="https://myshittycode.com/wp-content/uploads/2019/04/screen_shot_2019-04-26_at_12_22_30_pm-1.png 1446w, https://myshittycode.com/wp-content/uploads/2019/04/screen_shot_2019-04-26_at_12_22_30_pm-1-300x113.png 300w, https://myshittycode.com/wp-content/uploads/2019/04/screen_shot_2019-04-26_at_12_22_30_pm-1-1024x385.png 1024w, https://myshittycode.com/wp-content/uploads/2019/04/screen_shot_2019-04-26_at_12_22_30_pm-1-768x289.png 768w" sizes="auto, (max-width: 1446px) 100vw, 1446px" /></figure>



<p>In the &#8220;Registry&#8221; dialog:-</p>



<ul class="wp-block-list">
<li>Find &#8220;compiler.automake.allow.when.app.running&#8221; key.</li>



<li>Check the checkbox.</li>



<li>Close the dialog.</li>
</ul>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="1358" height="1244" src="https://myshittycode.com/wp-content/uploads/2019/04/screen_shot_2019-04-26_at_12_26_04_pm-1.png?x45560" alt="" class="wp-image-1098" srcset="https://myshittycode.com/wp-content/uploads/2019/04/screen_shot_2019-04-26_at_12_26_04_pm-1.png 1358w, https://myshittycode.com/wp-content/uploads/2019/04/screen_shot_2019-04-26_at_12_26_04_pm-1-300x275.png 300w, https://myshittycode.com/wp-content/uploads/2019/04/screen_shot_2019-04-26_at_12_26_04_pm-1-1024x938.png 1024w, https://myshittycode.com/wp-content/uploads/2019/04/screen_shot_2019-04-26_at_12_26_04_pm-1-768x704.png 768w" sizes="auto, (max-width: 1358px) 100vw, 1358px" /></figure>



<p>In IntelliJ IDEA &#8220;Preferences&#8221; dialog:-</p>



<ul class="wp-block-list">
<li>Go to &#8220;Build, Execution, Deployment&#8221; » &#8220;Compiler&#8221;.</li>



<li>Check &#8220;Build project automatically&#8221;.</li>



<li>Close the dialog.</li>
</ul>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="2126" height="1368" src="https://myshittycode.com/wp-content/uploads/2019/04/screen_shot_2019-04-26_at_12_28_40_pm-1.png?x45560" alt="" class="wp-image-1099" srcset="https://myshittycode.com/wp-content/uploads/2019/04/screen_shot_2019-04-26_at_12_28_40_pm-1.png 2126w, https://myshittycode.com/wp-content/uploads/2019/04/screen_shot_2019-04-26_at_12_28_40_pm-1-300x193.png 300w, https://myshittycode.com/wp-content/uploads/2019/04/screen_shot_2019-04-26_at_12_28_40_pm-1-1024x659.png 1024w, https://myshittycode.com/wp-content/uploads/2019/04/screen_shot_2019-04-26_at_12_28_40_pm-1-768x494.png 768w, https://myshittycode.com/wp-content/uploads/2019/04/screen_shot_2019-04-26_at_12_28_40_pm-1-1536x988.png 1536w, https://myshittycode.com/wp-content/uploads/2019/04/screen_shot_2019-04-26_at_12_28_40_pm-1-2048x1318.png 2048w" sizes="auto, (max-width: 2126px) 100vw, 2126px" /></figure>



<p>Finally, instead of running Maven goals to run the Spring Boot app, select the Application class (annotated with <b>@SpringBootApplication</b>) and run it from IntelliJ IDEA.</p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="476" height="102" src="https://myshittycode.com/wp-content/uploads/2019/04/screen_shot_2019-04-26_at_12_31_18_pm-1.png?x45560" alt="" class="wp-image-1100" srcset="https://myshittycode.com/wp-content/uploads/2019/04/screen_shot_2019-04-26_at_12_31_18_pm-1.png 476w, https://myshittycode.com/wp-content/uploads/2019/04/screen_shot_2019-04-26_at_12_31_18_pm-1-300x64.png 300w" sizes="auto, (max-width: 476px) 100vw, 476px" /></figure>



<p>Anytime the app&#8217;s class files have changed, IntelliJ IDEA will compile the app, which will then trigger Spring Boot Dev Tools to restart the app.</p>
<p>The post <a rel="nofollow" href="https://myshittycode.com/2019/04/26/spring-boot-restarting-app-using-dev-tools-in-intellij-idea/">Spring Boot: Restarting App using Dev Tools with IntelliJ IDEA</a> appeared first on <a rel="nofollow" href="https://myshittycode.com">My Shitty Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://myshittycode.com/2019/04/26/spring-boot-restarting-app-using-dev-tools-in-intellij-idea/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1096</post-id>	</item>
		<item>
		<title>IntelliJ IDEA: Configuring Default Project Settings</title>
		<link>https://myshittycode.com/2015/11/03/intellij-idea-configuring-default-project-settings/</link>
					<comments>https://myshittycode.com/2015/11/03/intellij-idea-configuring-default-project-settings/#respond</comments>
		
		<dc:creator><![CDATA[Shitty Author]]></dc:creator>
		<pubDate>Tue, 03 Nov 2015 17:21:43 +0000</pubDate>
				<category><![CDATA[Development Tools]]></category>
		<category><![CDATA[IntelliJ IDEA]]></category>
		<guid isPermaLink="false">http://myshittycode.com/?p=851</guid>

					<description><![CDATA[<p>PROBLEM When creating or checking out a project for the first time in IntelliJ IDEA, we may need to reconfigure the project settings. My biggest pain is IntelliJ IDEA will always use the wrong Maven version when I check out the project from the source control. SOLUTION The good news is there is a way [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://myshittycode.com/2015/11/03/intellij-idea-configuring-default-project-settings/">IntelliJ IDEA: Configuring Default Project Settings</a> appeared first on <a rel="nofollow" href="https://myshittycode.com">My Shitty Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">PROBLEM</h2>



<p>When creating or checking out a project for the first time in IntelliJ IDEA, we may need to reconfigure the project settings. My biggest pain is IntelliJ IDEA will always use the wrong Maven version when I check out the project from the source control.</p>



<h2 class="wp-block-heading">SOLUTION</h2>



<p>The good news is there is a way to set up default project settings in IntelliJ IDEA.</p>



<p>In the <strong>Welcome</strong> dialog, select <b>Configure -&gt; Project Defaults</b>.</p>



<figure class="wp-block-image aligncenter"><img loading="lazy" decoding="async" width="906" height="657" src="https://myshittycode.com/wp-content/uploads/2015/11/screen-shot-2015-11-03-at-10-26-57-am-1.png?x45560" alt="" class="wp-image-852" srcset="https://myshittycode.com/wp-content/uploads/2015/11/screen-shot-2015-11-03-at-10-26-57-am-1.png 906w, https://myshittycode.com/wp-content/uploads/2015/11/screen-shot-2015-11-03-at-10-26-57-am-1-300x218.png 300w, https://myshittycode.com/wp-content/uploads/2015/11/screen-shot-2015-11-03-at-10-26-57-am-1-768x557.png 768w" sizes="auto, (max-width: 906px) 100vw, 906px" /></figure>



<p>From here, we can create all the default project settings, such as JDK version, Maven version, code style formatter and so on.</p>
<p>The post <a rel="nofollow" href="https://myshittycode.com/2015/11/03/intellij-idea-configuring-default-project-settings/">IntelliJ IDEA: Configuring Default Project Settings</a> appeared first on <a rel="nofollow" href="https://myshittycode.com">My Shitty Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://myshittycode.com/2015/11/03/intellij-idea-configuring-default-project-settings/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">851</post-id>	</item>
		<item>
		<title>IntelliJ IDEA 14.1: Better equals(), hashCode() and toString()</title>
		<link>https://myshittycode.com/2015/07/21/intellij-idea-14-1-better-equals-hashcode-and-tostring/</link>
					<comments>https://myshittycode.com/2015/07/21/intellij-idea-14-1-better-equals-hashcode-and-tostring/#respond</comments>
		
		<dc:creator><![CDATA[Shitty Author]]></dc:creator>
		<pubDate>Tue, 21 Jul 2015 15:23:47 +0000</pubDate>
				<category><![CDATA[Programming Language]]></category>
		<category><![CDATA[Development Tools]]></category>
		<category><![CDATA[Guava]]></category>
		<category><![CDATA[IntelliJ IDEA]]></category>
		<category><![CDATA[Java]]></category>
		<guid isPermaLink="false">http://myshittycode.com/?p=740</guid>

					<description><![CDATA[<p>PROBLEM Let&#8217;s assume we want to create the default equals(), hashCode() and toString() with the following bean:- Most IDEs, including older version of IntelliJ, have code generation features that would create something similar to this:- While it works, the generated code is usually crazy horrendous. SOLUTION With IntelliJ 14.x, it allows us to select templates [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://myshittycode.com/2015/07/21/intellij-idea-14-1-better-equals-hashcode-and-tostring/">IntelliJ IDEA 14.1: Better equals(), hashCode() and toString()</a> appeared first on <a rel="nofollow" href="https://myshittycode.com">My Shitty Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">PROBLEM</h2>



<p>Let&#8217;s assume we want to create the default <b>equals()</b>, <b>hashCode()</b> and <b>toString()</b> with the following bean:-</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: java; title: ; notranslate">
public final class Person {
    private final String name;
    private final Collection&lt;car&gt; cars;

    public Person(final String name, final Collection&lt;car&gt; cars) {
        this.name = name;
        this.cars = cars;
    }

    public String getName() {
        return name;
    }

    public Collection&lt;car&gt; getCars() {
        return cars;
    }
}
</pre></div>


<p>Most IDEs, including older version of IntelliJ, have code generation features that would create something similar to this:-</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: java; title: ; notranslate">
public final class Person {
    ...

    @Override
    public boolean equals(final Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        final Person person = (Person) o;

        if (name != null ? !name.equals(person.name) : person.name != null) {
            return false;
        }
        return !(cars != null ? !cars.equals(person.cars) : person.cars != null);
    }

    @Override
    public int hashCode() {
        int result = name != null ? name.hashCode() : 0;
        result = 31 * result + (cars != null ? cars.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        return &quot;Person{&quot; +
               &quot;name=&#039;&quot; + name + &#039;\&#039;&#039; +
               &quot;, cars=&quot; + cars +
               &#039;}&#039;;
    }
}
</pre></div>


<p>While it works, the generated code is usually crazy horrendous.</p>



<h2 class="wp-block-heading">SOLUTION</h2>



<p>With IntelliJ 14.x, it allows us to select templates from several proven libraries.</p>



<p>To generate <b>equals()</b> and <b>hashCode()</b>, select <b>equals() and hashCode()</b> option from the <b>Generate</b> pop-up dialog:-</p>



<figure class="wp-block-image aligncenter"><img loading="lazy" decoding="async" width="496" height="378" src="https://myshittycode.com/wp-content/uploads/2015/07/screen-shot-2015-07-21-at-10-08-23-am-1.png?x45560" alt="" class="wp-image-745" srcset="https://myshittycode.com/wp-content/uploads/2015/07/screen-shot-2015-07-21-at-10-08-23-am-1.png 496w, https://myshittycode.com/wp-content/uploads/2015/07/screen-shot-2015-07-21-at-10-08-23-am-1-300x229.png 300w" sizes="auto, (max-width: 496px) 100vw, 496px" /></figure>



<p>There are several templates to choose from:-</p>



<figure class="wp-block-image aligncenter"><img loading="lazy" decoding="async" width="482" height="382" src="https://myshittycode.com/wp-content/uploads/2015/07/screen-shot-2015-07-21-at-10-09-05-am-1.png?x45560" alt="" class="wp-image-746" srcset="https://myshittycode.com/wp-content/uploads/2015/07/screen-shot-2015-07-21-at-10-09-05-am-1.png 482w, https://myshittycode.com/wp-content/uploads/2015/07/screen-shot-2015-07-21-at-10-09-05-am-1-300x238.png 300w" sizes="auto, (max-width: 482px) 100vw, 482px" /></figure>



<p>Here&#8217;s an example of <b>equals()</b> and <b>hashCode()</b> using Guava and getter methods:-</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: java; title: ; notranslate">
public final class Person {
    ...

    @Override
    public boolean equals(final Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        final Person person = (Person) o;
        return Objects.equal(getName(), person.getName()) &amp;amp;amp;&amp;amp;amp;
               Objects.equal(getCars(), person.getCars());
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(getName(), getCars());
    }
}
</pre></div>


<p>To generate <b>toString()</b>, select <b>toString()</b> option from the <b>Generate</b> pop-up dialog:-</p>



<figure class="wp-block-image aligncenter"><img loading="lazy" decoding="async" width="395" height="313" src="https://myshittycode.com/wp-content/uploads/2015/07/screen-shot-2015-07-21-at-10-10-06-am-1.png?x45560" alt="" class="wp-image-747" srcset="https://myshittycode.com/wp-content/uploads/2015/07/screen-shot-2015-07-21-at-10-10-06-am-1.png 395w, https://myshittycode.com/wp-content/uploads/2015/07/screen-shot-2015-07-21-at-10-10-06-am-1-300x238.png 300w" sizes="auto, (max-width: 395px) 100vw, 395px" /></figure>



<p>Again, there are several templates to choose from:-</p>



<figure class="wp-block-image aligncenter"><img loading="lazy" decoding="async" width="504" height="298" src="https://myshittycode.com/wp-content/uploads/2015/07/screen-shot-2015-07-21-at-10-10-45-am-1.png?x45560" alt="" class="wp-image-748" srcset="https://myshittycode.com/wp-content/uploads/2015/07/screen-shot-2015-07-21-at-10-10-45-am-1.png 504w, https://myshittycode.com/wp-content/uploads/2015/07/screen-shot-2015-07-21-at-10-10-45-am-1-300x177.png 300w" sizes="auto, (max-width: 504px) 100vw, 504px" /></figure>



<p>Here&#8217;s an example of <b>toString()</b> using Guava:-</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: java; title: ; notranslate">
public final class Person {
    ...

    @Override
    public String toString() {
        return Objects.toStringHelper(this)
                .add(&quot;name&quot;, name)
                .add(&quot;cars&quot;, cars)
                .toString();
    }
}
</pre></div><p>The post <a rel="nofollow" href="https://myshittycode.com/2015/07/21/intellij-idea-14-1-better-equals-hashcode-and-tostring/">IntelliJ IDEA 14.1: Better equals(), hashCode() and toString()</a> appeared first on <a rel="nofollow" href="https://myshittycode.com">My Shitty Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://myshittycode.com/2015/07/21/intellij-idea-14-1-better-equals-hashcode-and-tostring/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">740</post-id>	</item>
		<item>
		<title>IntelliJ IDEA: Generating Immutable Classes and Fields</title>
		<link>https://myshittycode.com/2015/06/29/intellij-idea-generating-immutable-classes-and-fields/</link>
					<comments>https://myshittycode.com/2015/06/29/intellij-idea-generating-immutable-classes-and-fields/#respond</comments>
		
		<dc:creator><![CDATA[Shitty Author]]></dc:creator>
		<pubDate>Mon, 29 Jun 2015 16:39:13 +0000</pubDate>
				<category><![CDATA[Programming Language]]></category>
		<category><![CDATA[Development Tools]]></category>
		<category><![CDATA[IntelliJ IDEA]]></category>
		<category><![CDATA[Java]]></category>
		<guid isPermaLink="false">http://myshittycode.com/?p=727</guid>

					<description><![CDATA[<p>PROBLEM By default, IntelliJ IDEA generates mutable classes and fields. One of the steps to achieve immutability is to make all classes and fields to be final. SOLUTION Making Fields Final Go to Preferences&#8230; -&#62; Code Style -&#62; Java -&#62; Code Generation tab Under Final Modifier, check both Make generated local variables final and Make [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://myshittycode.com/2015/06/29/intellij-idea-generating-immutable-classes-and-fields/">IntelliJ IDEA: Generating Immutable Classes and Fields</a> appeared first on <a rel="nofollow" href="https://myshittycode.com">My Shitty Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">PROBLEM</h2>



<p>By default, IntelliJ IDEA generates mutable classes and fields.</p>



<p>One of the steps to achieve immutability is to make all classes and fields to be final.</p>



<h2 class="wp-block-heading">SOLUTION</h2>



<h4 class="wp-block-heading">Making Fields Final</h4>



<p>Go to <b>Preferences&#8230; -&gt; Code Style -&gt; Java -&gt; Code Generation tab</b></p>



<p>Under <b>Final Modifier</b>, check both <b>Make generated local variables final</b> and <b>Make generated parameters final</b>.</p>



<figure class="wp-block-image aligncenter"><img loading="lazy" decoding="async" width="974" height="544" src="https://myshittycode.com/wp-content/uploads/2015/06/screen-shot-2015-06-29-at-11_17_16-am-1.jpg?x45560" alt="" class="wp-image-728" srcset="https://myshittycode.com/wp-content/uploads/2015/06/screen-shot-2015-06-29-at-11_17_16-am-1.jpg 974w, https://myshittycode.com/wp-content/uploads/2015/06/screen-shot-2015-06-29-at-11_17_16-am-1-300x168.jpg 300w, https://myshittycode.com/wp-content/uploads/2015/06/screen-shot-2015-06-29-at-11_17_16-am-1-768x429.jpg 768w" sizes="auto, (max-width: 974px) 100vw, 974px" /></figure>



<h4 class="wp-block-heading">Making Classes Final</h4>



<p>Go to <b>Preferences&#8230; -&gt; File and Code Templates -&gt; Templates tab</b></p>



<p>Select <b>Class</b> and add <b>final</b>.</p>



<figure class="wp-block-image aligncenter"><img loading="lazy" decoding="async" width="983" height="456" src="https://myshittycode.com/wp-content/uploads/2015/06/screen_shot_2015-06-29_at_11_18_21_am-1.png?x45560" alt="" class="wp-image-729" srcset="https://myshittycode.com/wp-content/uploads/2015/06/screen_shot_2015-06-29_at_11_18_21_am-1.png 983w, https://myshittycode.com/wp-content/uploads/2015/06/screen_shot_2015-06-29_at_11_18_21_am-1-300x139.png 300w, https://myshittycode.com/wp-content/uploads/2015/06/screen_shot_2015-06-29_at_11_18_21_am-1-768x356.png 768w" sizes="auto, (max-width: 983px) 100vw, 983px" /></figure>
<p>The post <a rel="nofollow" href="https://myshittycode.com/2015/06/29/intellij-idea-generating-immutable-classes-and-fields/">IntelliJ IDEA: Generating Immutable Classes and Fields</a> appeared first on <a rel="nofollow" href="https://myshittycode.com">My Shitty Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://myshittycode.com/2015/06/29/intellij-idea-generating-immutable-classes-and-fields/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">727</post-id>	</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 
Lazy Loading (feed)
Database Caching using Disk

Served from: myshittycode.com @ 2026-02-21 12:42:56 by W3 Total Cache
-->