<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jannik Hell on Medium]]></title>
        <description><![CDATA[Stories by Jannik Hell on Medium]]></description>
        <link>https://medium.com/@joeclever?source=rss-957c3b96626------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*zsP8bg6IyNAJWy1LSDdr3g.jpeg</url>
            <title>Stories by Jannik Hell on Medium</title>
            <link>https://medium.com/@joeclever?source=rss-957c3b96626------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 04:52:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@joeclever/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Why TypeScript fits my way of thinking]]></title>
            <link>https://medium.com/@joeclever/why-typescript-fits-my-way-of-thinking-85056f1bdefe?source=rss-957c3b96626------2</link>
            <guid isPermaLink="false">https://medium.com/p/85056f1bdefe</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Jannik Hell]]></dc:creator>
            <pubDate>Sun, 03 Mar 2019 23:19:50 GMT</pubDate>
            <atom:updated>2019-03-03T23:19:50.474Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eKttj3x53hHZQgiymtjkvg.jpeg" /></figure><p>I recently had a great time writing Node apps with TypeScript and I want to share my experience with you.</p><p><strong>tl;dr</strong>: The combination of JavaScript and TypeScript makes me productive and confident about my code.</p><p>Before I write code I tend to split the work into separate logical tasks. Tasks get some data in maybe perform some kind of side effect like an API call and eventually return data back for further processing.</p><p>When I reach such a new task in my code I intuitively write a function call. Since that task is already in my mental model it is easy to find a name for that function. Whats not so clear at that point of time is which data is actually necessary as input to the function to perform the task and how the data coming back from the function looks like.</p><p>Since JavaScript is valid TypeScript I now write the actual function in pure JavaScript. During the process of implementing the function I possibly come up with more needed input data and add it as a new parameter. After implementing the happy path the returned data type or structure appears.</p><p>After adding appropriate arguments to the function call the code may now already run without any errors.</p><p>Until this point I utilized the aspect of the dynamic typing in JavaScript. It was nice to have this great flexibility for experimenting and discovering the actual dependencies and return value of the function. But to be confident about the code, preventing runtime errors and preventing bugs in the future there is some kind of contract needed for this function. To ensure the validity of incoming and outgoing data I now add TypeScript types to the parameters and the return value.</p><p>Now it’s time to assign the return value to a new variable. With TypeScript automatically inferring the type of that variable it’s possible to get type safeness and all the great features like autocompletion that come with it without having types cluttered all over the codebase which might distract readers of the code.</p><h3>Conclusion</h3><p>The combination of JavaScript and TypeScript enables a workflow that fits my way of thinking really well. Having such a nice fitting workflow makes me productive and confident about my code. JavaScript is great for quick prototyping and exploring the solution. TypeScript makes the code bulletproof.</p><p>I hope that this blog post inspired you to try out this workflow. Let me know if you’ve also established a workflow that fits your individual way of thinking.</p><p>Thanks for reading. 🙂</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=85056f1bdefe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Integration Testing multiple datasources in Spring Boot and Spring Data with Spock ]]></title>
            <link>https://medium.com/@joeclever/integration-testing-multiple-datasources-in-spring-boot-and-spring-data-with-spock-f88e1428ce9f?source=rss-957c3b96626------2</link>
            <guid isPermaLink="false">https://medium.com/p/f88e1428ce9f</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[multiple-datasources]]></category>
            <category><![CDATA[spring-data]]></category>
            <dc:creator><![CDATA[Jannik Hell]]></dc:creator>
            <pubDate>Sat, 13 May 2017 18:57:50 GMT</pubDate>
            <atom:updated>2017-05-15T15:41:33.285Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6OgvczgRlJhMApojbt3o2g.jpeg" /></figure><p>For Integration Tests <a href="https://projects.spring.io/spring-boot/"><strong>Spring Boot</strong></a> provides an easy way to use an <strong>In-Memory </strong><a href="https://en.wikipedia.org/wiki/H2_(DBMS)"><strong>H2</strong></a> database instead of a real one when you have just one <strong>single datasource</strong> in your application:@AutoConfigureTestDatabase. But what if you have <strong>multiple datasources</strong> that you want to replace with In-Memory ones during your tests?</p><p>Spring Boot <strong>doesn’t support</strong> this scenario <strong>out of the box</strong> but luckily there is a way of doing this!</p><p>In my <a href="https://medium.com/@joeclever/using-multiple-datasources-with-spring-boot-and-spring-data-6430b00c02e7">last blog post</a> I described <strong>how to use multiple datasources</strong> in a Spring Boot + Spring Data application. Maybe that’s interesting for you too.</p><p>I provided an example project with two PostgreSQL datasources on GitHub: <a href="https://github.com/jahe/spring-boot-multiple-datasources">https://github.com/jahe/spring-boot-multiple-datasources</a></p><p>I use <a href="http://spockframework.org/"><strong>Spock</strong></a> to write my tests but <a href="http://junit.org/">JUnit</a> works too. Both of them can live side by side in a project as Spock runs on top of the JUnit runner.</p><h4>1. Add the following dependencies to your pom.xml</h4><pre><em>&lt;!-- TEST DEPENDENCIES --&gt;<br>&lt;!-- Spring Boot Starter Test --&gt;<br></em>&lt;<strong>dependency</strong>&gt;<br> &lt;<strong>groupId</strong>&gt;org.springframework.boot&lt;/<strong>groupId</strong>&gt;<br> &lt;<strong>artifactId</strong>&gt;spring-boot-starter-test&lt;/<strong>artifactId</strong>&gt;<br> &lt;<strong>scope</strong>&gt;test&lt;/<strong>scope</strong>&gt;<br>&lt;/<strong>dependency</strong>&gt;<br><br><em>&lt;!-- Spock (A Groovy based testframework running on top of the JUnit runner)  --&gt;<br>&lt;!-- https://mvnrepository.com/artifact/org.spockframework/spock-core --&gt;<br></em>&lt;<strong>dependency</strong>&gt;<br> &lt;<strong>groupId</strong>&gt;org.spockframework&lt;/<strong>groupId</strong>&gt;<br> &lt;<strong>artifactId</strong>&gt;spock-core&lt;/<strong>artifactId</strong>&gt;<br> &lt;<strong>version</strong>&gt;1.1-groovy-2.4&lt;/<strong>version</strong>&gt;<br> &lt;<strong>scope</strong>&gt;test&lt;/<strong>scope</strong>&gt;<br>&lt;/<strong>dependency</strong>&gt;<br><br><em>&lt;!-- Spock-Spring: Use the Spring TestContext framework together with Spock for Integration Tests --&gt;<br>&lt;!-- https://mvnrepository.com/artifact/org.spockframework/spock-spring --&gt;<br></em>&lt;<strong>dependency</strong>&gt;<br> &lt;<strong>groupId</strong>&gt;org.spockframework&lt;/<strong>groupId</strong>&gt;<br> &lt;<strong>artifactId</strong>&gt;spock-spring&lt;/<strong>artifactId</strong>&gt;<br> &lt;<strong>version</strong>&gt;1.1-groovy-2.4&lt;/<strong>version</strong>&gt;<br> &lt;<strong>scope</strong>&gt;test&lt;/<strong>scope</strong>&gt;<br>&lt;/<strong>dependency</strong>&gt;<br><br><em>&lt;!-- Specific Groovy version for using Spock (needed by the Maven Plugins) --&gt;<br>&lt;!-- Use a specific Groovy version rather than the one specified by spock-core --&gt;<br></em>&lt;<strong>dependency</strong>&gt;<br> &lt;<strong>groupId</strong>&gt;org.codehaus.groovy&lt;/<strong>groupId</strong>&gt;<br> &lt;<strong>artifactId</strong>&gt;groovy-all&lt;/<strong>artifactId</strong>&gt;<br> &lt;<strong>version</strong>&gt;2.4.10&lt;/<strong>version</strong>&gt; <em>&lt;!-- 2.4.11 didn&#39;t work for me --&gt;<br> </em>&lt;<strong>scope</strong>&gt;test&lt;/<strong>scope</strong>&gt;<br>&lt;/<strong>dependency</strong>&gt;<br><br><em>&lt;!-- H2 In-Memory Database JDBC driver for tests --&gt;<br></em>&lt;<strong>dependency</strong>&gt;<br> &lt;<strong>groupId</strong>&gt;com.h2database&lt;/<strong>groupId</strong>&gt;<br> &lt;<strong>artifactId</strong>&gt;h2&lt;/<strong>artifactId</strong>&gt;<br> &lt;<strong>version</strong>&gt;1.4.195&lt;/<strong>version</strong>&gt;<br> &lt;<strong>scope</strong>&gt;test&lt;/<strong>scope</strong>&gt;<br>&lt;/<strong>dependency</strong>&gt;</pre><h4>2. Add the following Maven plugins to your pom.xml</h4><pre><em>&lt;!-- Spock related Plugins --&gt;<br>&lt;!-- Mandatory plugins for using Spock --&gt;<br></em>&lt;<strong>plugin</strong>&gt;<br> <em>&lt;!-- The gmavenplus plugin is used to compile Groovy code. To learn more about this plugin,<br> visit https://github.com/groovy/GMavenPlus/wiki --&gt;<br> </em>&lt;<strong>groupId</strong>&gt;org.codehaus.gmavenplus&lt;/<strong>groupId</strong>&gt;<br> &lt;<strong>artifactId</strong>&gt;gmavenplus-plugin&lt;/<strong>artifactId</strong>&gt;<br> &lt;<strong>version</strong>&gt;1.5&lt;/<strong>version</strong>&gt;<br> &lt;<strong>executions</strong>&gt;<br>  &lt;<strong>execution</strong>&gt;<br>   &lt;<strong>goals</strong>&gt;<br>    &lt;<strong>goal</strong>&gt;compile&lt;/<strong>goal</strong>&gt;<br>    &lt;<strong>goal</strong>&gt;testCompile&lt;/<strong>goal</strong>&gt;<br>   &lt;/<strong>goals</strong>&gt;<br>  &lt;/<strong>execution</strong>&gt;<br> &lt;/<strong>executions</strong>&gt;<br>&lt;/<strong>plugin</strong>&gt;<br><em>&lt;!-- Optional plugins for using Spock --&gt;<br>&lt;!-- Only required if names of spec classes don&#39;t match default Surefire patterns (`*Test` etc.) --&gt;<br></em>&lt;<strong>plugin</strong>&gt;<br> &lt;<strong>groupId</strong>&gt;org.apache.maven.plugins&lt;/<strong>groupId</strong>&gt;<br> &lt;<strong>artifactId</strong>&gt;maven-surefire-plugin&lt;/<strong>artifactId</strong>&gt;<br> &lt;<strong>version</strong>&gt;2.20&lt;/<strong>version</strong>&gt;<br> &lt;<strong>configuration</strong>&gt;<br>  &lt;<strong>useFile</strong>&gt;false&lt;/<strong>useFile</strong>&gt;<br>  &lt;<strong>includes</strong>&gt;<br>   &lt;<strong>include</strong>&gt;**/*Spec.java&lt;/<strong>include</strong>&gt;<br>  &lt;/<strong>includes</strong>&gt;<br> &lt;/<strong>configuration</strong>&gt;<br>&lt;/<strong>plugin</strong>&gt;</pre><h4>3. Create an application.properties file in “src/test/resources” with the following content</h4><pre><em># Let Spring autodetect the different SQL Dialects of each datasource<br></em><strong>spring.jpa.database</strong>=<strong>default<br></strong><em># Generate the DB schema in the In-Memory H2 databases based on the JPA Entities<br></em><strong>spring.jpa.generate-ddl</strong>=<strong>true<br><br></strong><em># H2 In-Memory Database &quot;foo&quot; (used in tests instead of a real PostgreSQL DB)<br></em><strong>spring.datasource.url</strong>=<strong>jdbc:h2:mem:foo;DB_CLOSE_ON_EXIT=FALSE<br>spring.datasource.username</strong>=<strong>sa<br>spring.datasource.password</strong>=<br><strong>spring.datasource.driver-class-name</strong>=<strong>org.h2.Driver<br><br></strong><em># H2 In-Memory Database &quot;bar&quot; (used in tests instead of a real PostgreSQL DB)<br></em><strong>bar.datasource.url</strong>=<strong>jdbc:h2:mem:bar;DB_CLOSE_ON_EXIT=FALSE<br>bar.datasource.username</strong>=<strong>sa<br>bar.datasource.password</strong>=<br><strong>bar.datasource.driver-class-name</strong>=<strong>org.h2.Driver</strong></pre><h4>4. Create a “groovy” folder in “src/test” with your package structure inside</h4><pre>src/test/groovy<br>- com<br>    - foobar</pre><h4>5. Create your Spock Integration Test “FooBarITSpec.groovy” inside of “src/test/groovy/com.foobar”</h4><pre><strong>package </strong>com.foobar<br><br><strong>import </strong>com.foobar.bar.domain.Bar<br><strong>import </strong>com.foobar.bar.repo.BarRepository<br><strong>import </strong>com.foobar.foo.domain.Foo<br><strong>import </strong>com.foobar.foo.repo.FooRepository<br><strong>import </strong>org.springframework.beans.factory.annotation.Autowired<br><strong>import </strong>org.springframework.boot.test.context.SpringBootTest<br><strong>import </strong>org.springframework.boot.test.context.SpringBootTest.WebEnvironment<br><strong>import </strong>org.springframework.boot.test.web.client.TestRestTemplate<br><strong>import </strong>spock.lang.Specification<br><br>@SpringBootTest(webEnvironment = WebEnvironment.<strong><em>RANDOM_PORT</em></strong>)<br><strong>class </strong>FooBarITSpec <strong>extends </strong>Specification {<br><br>  @Autowired<br>  TestRestTemplate <strong>restTemplate<br><br>  </strong>@Autowired<br>  FooRepository <strong>fooRepo<br><br>  </strong>@Autowired<br>  BarRepository <strong>barRepo<br><br>  def &quot;Insert a Foo and a Bar Entity and retrieve the resulting String via GET /foobar/1&quot;</strong>() {<br>    <strong>given</strong>: <strong>&quot;A Foo and a Bar Entity&quot;<br>    fooRepo</strong>.save(<strong>[<br>      foo</strong>: <strong>&quot;Hello&quot;<br>    ] as </strong>Foo)<br><br>    <strong>barRepo</strong>.save(<strong>[<br>      bar</strong>: <strong>&quot;World&quot;<br>    ] as </strong>Bar)<br><br>    <strong>when</strong>: <strong>&quot;GET /foobar/1&quot;<br>    def </strong>result = <strong>restTemplate</strong>.getForObject(<strong>&quot;/foobar/1&quot;</strong>, String.<strong>class</strong>)<br><br>    <strong>then</strong>: <strong>&quot;The result is \&quot;Hello World!\&quot;&quot;<br>    </strong>result == <strong>&quot;Hello World!&quot;<br>    <br>    cleanup</strong>:<br>    <strong>fooRepo</strong>.deleteAll()<br>    <strong>barRepo</strong>.deleteAll()<br>  }<br>}</pre><h4>6. Run the test with Maven</h4><pre>&gt;<strong> mvn test</strong></pre><pre>[INFO] -------------------------------------------------------<br>[INFO]  T E S T S<br>[INFO] -------------------------------------------------------<br>[INFO] Running com.foobar.FooBarITSpec<br>...<br>[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 7.908 s - in com.foobar.FooBarITSpec<br>...<br>[INFO] Results:<br>[INFO] <br>[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0<br>[INFO] <br>[INFO] -------------------------------------------------------<br>[INFO] BUILD SUCCESS<br>[INFO] -------------------------------------------------------<br>[INFO] Total time: 19.762 s<br>[INFO] Finished at: 2017-05-13T19:47:00+02:00<br>[INFO] Final Memory: 36M/297M<br>[INFO] -------------------------------------------------------</pre><h4>Done. 👍</h4><p>If you want to run the test in <strong>IntelliJ IDEA</strong> you have to Rightclick the groovy directory <strong>&gt;</strong> Mark directory as <strong>&gt;</strong>Test Sources Root.</p><p><strong>Thanks for reading</strong> and feel free to comment.</p><p><strong>Follow me on</strong> <strong>Twitter</strong> if you like: <a href="https://twitter.com/joeclever">@joeclever</a></p><p>Example project with two PostgreSQL datasources: <a href="https://github.com/jahe/spring-boot-multiple-datasources">https://github.com/jahe/spring-boot-multiple-datasources</a></p><p>My last blog post: <a href="https://medium.com/@joeclever/using-multiple-datasources-with-spring-boot-and-spring-data-6430b00c02e7">Using multiple datasources with Spring Boot and Spring Data 💈 ⇄🌱 ⇄ 💈</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f88e1428ce9f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using multiple datasources with Spring Boot and Spring Data  ⇄ ⇄ ]]></title>
            <link>https://medium.com/@joeclever/using-multiple-datasources-with-spring-boot-and-spring-data-6430b00c02e7?source=rss-957c3b96626------2</link>
            <guid isPermaLink="false">https://medium.com/p/6430b00c02e7</guid>
            <category><![CDATA[spring]]></category>
            <category><![CDATA[multiple-datasources]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[spring-data]]></category>
            <dc:creator><![CDATA[Jannik Hell]]></dc:creator>
            <pubDate>Thu, 04 May 2017 19:46:39 GMT</pubDate>
            <atom:updated>2017-07-30T22:05:49.581Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*BIr4H5Mef4e65vNWZpwYnw.jpeg" /></figure><p><a href="https://projects.spring.io/spring-boot/"><strong>Spring Boot</strong></a> with <a href="http://projects.spring.io/spring-data/"><strong>Spring Data</strong></a> makes it easy to access a database through so called Repositories. But what if you want to access <strong>multiple databases</strong> maybe even with different Database Management Systems?</p><p>Luckily Spring provides a way of doing this.</p><p>I provided an example project with two PostgreSQL datasources on GitHub: <a href="https://github.com/jahe/spring-boot-multiple-datasources">https://github.com/jahe/spring-boot-multiple-datasources</a></p><h4>1. Add an additional datasource configuration to your application.properties</h4><pre># Oracle DB - &quot;foo&quot;<br>spring.datasource.url=jdbc:oracle:thin:@//db-server-foo:1521/FOO<br>spring.datasource.username=fooadmin<br>spring.datasource.password=foo123<em><br></em>spring.datasource.driver-class-name=oracle.jdbc.OracleDriver</pre><pre># PostgreSQL DB - &quot;bar&quot;<br>bar.datasource.url=jdbc:postgresql://db-server-bar:5432/bar<br>bar.datasource.username=baradmin<br>bar.datasource.password=bar123<em><br></em>bar.datasource.driver-class-name=org.postgresql.Driver</pre><h4>2. Set the SQL Dialect to “default” in your application.properties to let Spring autodetect the different SQL Dialects of each datasource</h4><pre>spring.jpa.database=default</pre><h4>3. Create a Java Package for each datasource with two nested Packages “domain” and “repo”</h4><pre>src/main/java<br>- com.foobar<br>  - foo<br>    - domain<br>    - repo<br>  - bar<br>    - domain<br>    - repo</pre><h4>4. Create a Configuration Class for the Oracle database “foo” named “FooDbConfig.java”</h4><pre>package com.foobar;<br> <br>@Configuration<br>@EnableTransactionManagement<br>@EnableJpaRepositories(<br>  entityManagerFactoryRef = &quot;entityManagerFactory&quot;,<br>  basePackages = { &quot;com.foobar.foo.repo&quot; }<br>)<br>public class FooDbConfig {<br>  <br>  @Primary<br>  @Bean(name = &quot;dataSource&quot;)<br>  @ConfigurationProperties(prefix = &quot;spring.datasource&quot;)<br>  public DataSource dataSource() {<br>    return DataSourceBuilder.<em>create</em>().build();<br>  }<br>  <br>  @Primary<br>  @Bean(name = &quot;entityManagerFactory&quot;)<br>  public LocalContainerEntityManagerFactoryBean <br>  entityManagerFactory(<br>    EntityManagerFactoryBuilder builder,<br>    @Qualifier(&quot;dataSource&quot;) DataSource dataSource<br>  ) {<br>    return builder<br>      .dataSource(dataSource)<br>      .packages(&quot;com.foobar.foo.domain&quot;)<br>      .persistenceUnit(&quot;foo&quot;)<br>      .build();<br>  }<br>    <br>  @Primary<br>  @Bean(name = &quot;transactionManager&quot;)<br>  public PlatformTransactionManager transactionManager(<br>    @Qualifier(&quot;entityManagerFactory&quot;) EntityManagerFactory <br>    entityManagerFactory<br>  ) {<br>    return new JpaTransactionManager(entityManagerFactory);<br>  }<br>}</pre><h4>5. Create a Configuration Class for the PostgreSQL database “bar” named “BarDbConfig.java”</h4><pre>package com.foobar;<br><br>@Configuration<br>@EnableTransactionManagement<br>@EnableJpaRepositories(<br>  entityManagerFactoryRef = &quot;barEntityManagerFactory&quot;,<br>  transactionManagerRef = &quot;barTransactionManager&quot;,<br>  basePackages = { &quot;com.foobar.bar.repo&quot; }<br>)<br>public class BarDbConfig {<br> <br>  @Bean(name = &quot;barDataSource&quot;)<br>  @ConfigurationProperties(prefix = &quot;bar.datasource&quot;)<br>  public DataSource dataSource() {<br>    return DataSourceBuilder.<em>create</em>().build();<br>  }<br>  <br>  @Bean(name = &quot;barEntityManagerFactory&quot;)<br>  public LocalContainerEntityManagerFactoryBean <br>  barEntityManagerFactory(<br>    EntityManagerFactoryBuilder builder,<br>    @Qualifier(&quot;barDataSource&quot;) DataSource dataSource<br>  ) {<br>    return<strong><br>      </strong>builder<br>        .dataSource(dataSource)<br>        .packages(&quot;com.foobar.bar.domain&quot;)<br>        .persistenceUnit(&quot;bar&quot;)<br>        .build();<br>  }</pre><pre>  @Bean(name = &quot;barTransactionManager&quot;)<br>  public PlatformTransactionManager barTransactionManager(<br>    @Qualifier(&quot;barEntityManagerFactory&quot;) EntityManagerFactory<br>    barEntityManagerFactory<br>  ) {<br>    return new JpaTransactionManager(barEntityManagerFactory);<br>  }<br>}</pre><h4>6. Create an Entity “Foo.java” for the Oracle database “foo”</h4><pre>package com.foobar.foo.domain;<br> <br>@Entity<br>@Table(name = &quot;FOO&quot;)<br>public class Foo {<br>  <br>  @Id<br>  @GeneratedValue<br>  @Column(name = &quot;ID&quot;)<br>  private Long id;<br>  <br>  @Column(name = &quot;FOO&quot;)<br>  private String foo;<br>  <br>  Foo(String foo) {<br>    this.foo = foo;<br>  }<br>  <br>  Foo() {<br>    // Default constructor needed by JPA<br>  }<br>}</pre><h4>7. Create a Repository “FooRepository.java” for the Oracle database “foo”</h4><pre>package com.foobar.foo.repo;<br> <br>@Repository<br>public interface FooRepository extends JpaRepository&lt;Foo, Long&gt; {<br>  <br>  Foo findById(Long id); <br>  <br>}</pre><h4>8. Create an Entity “Bar.java” for the PostgreSQL database “bar”</h4><pre>package com.foobar.bar.domain;<br> <br>@Entity<br>@Table(name = &quot;BAR&quot;)<br>public class Bar {<br>  <br>  @Id<br>  @GeneratedValue<br>  @Column(name = &quot;ID&quot;)<br>  private Long id;<br>  <br>  @Column(name = &quot;BAR&quot;)<br>  private String bar;<br>  <br>  Bar(String bar) {<br>    this.bar = bar;<br>  }<br>  <br>  Bar() {<br>    // Default constructor needed by JPA<br>  }<br>}</pre><h4>9. Create a Repository “BarRepository.java” for the PostgreSQL database “bar”</h4><pre>package com.foobar.bar.repo;<br> <br>@Repository<br>public interface BarRepository extends JpaRepository&lt;Bar, Long&gt; {<br>  <br>  Bar findById(Long id); <br>  <br>}</pre><h4>10. Create the Spring Boot Main Class “Application.java”</h4><pre>package com.foobar;<br> <br>@SpringBootApplication<br>public class Application {<br>  <br>  public static void main(String[] args) {<br>    SpringApplication.run(Application.class, args);<br>  }<br>  <br>}</pre><h4>11. Use the Repositories in a REST Controller (or somewhere else)</h4><pre>package com.foobar;<br> <br>@RestController<br>public class FooBarController {<br>  <br>  private final FooRepository fooRepo;<br>  private final BarRepository barRepo;<br>  <br>  @Autowired<br>  FooBarController(FooRepository fooRepo, BarRepository barRepo) {<br>    this.fooRepo = fooRepo;<br>    this.barRepo = barRepo;<br>  }<br>  <br>  @RequestMapping(&quot;/foobar/{id}&quot;)<br>  public String fooBar(@PathVariable(&quot;id&quot;) Long id) {<br>    Foo foo = fooRepo.findById(id);<br>    Bar bar = barRepo.findById(id);<br>    <br>    return foo.getFoo() + &quot; &quot; + bar.getBar(); <br>  }<br>}</pre><h4>Done. 👍</h4><p><strong>Thanks for reading</strong> and feel free to comment. 💛</p><p><strong>Follow me on</strong> <strong>Twitter</strong> if you like: <a href="https://twitter.com/joeclever"><strong>@joeclever</strong></a></p><p>Example project with two PostgreSQL datasources: <a href="https://github.com/jahe/spring-boot-multiple-datasources">https://github.com/jahe/spring-boot-multiple-datasources</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6430b00c02e7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Three simple ways to inspect a Webpack bundle]]></title>
            <link>https://medium.com/@joeclever/three-simple-ways-to-inspect-a-webpack-bundle-7f6a8fe7195d?source=rss-957c3b96626------2</link>
            <guid isPermaLink="false">https://medium.com/p/7f6a8fe7195d</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[analysis]]></category>
            <category><![CDATA[webpack]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Jannik Hell]]></dc:creator>
            <pubDate>Wed, 25 Jan 2017 21:26:41 GMT</pubDate>
            <atom:updated>2017-07-30T22:18:32.631Z</atom:updated>
            <content:encoded><![CDATA[<p>Webpack is a module bundler which means that it bundles together all of your JavaScript files to one or multiple files commonly named <em>bundle.js</em>.</p><p>To inspect this bundle in terms of file size and composition there are three tools I find very helpful.</p><h3>Webpack Visualizer</h3><p>I use <a href="https://chrisbateman.github.io/webpack-visualizer/">Webpack Visualizer</a> pretty heavily. It gives you a nice visual overview about the parts of your bundle.</p><p>Webpack Visualizer takes a <em>webpack-stats.json</em> file that Webpack generates with the following command:</p><pre>webpack --profile --json &gt; webpack-stats.json</pre><p>Drag &amp; Drop this file into the Webpack Visualizer site to get the following result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wd9WV0iEXmfKdU-DT-HgDQ.png" /><figcaption><a href="https://chrisbateman.github.io/webpack-visualizer/">Webpack Visualizer</a> output</figcaption></figure><h3>Webpack Analyzer</h3><p>The <a href="https://webpack.github.io/analyse/">Webpack Analyzer</a> gives you a more comprehensive analysis of your bundle.</p><p>It draws a graph of all dependent modules in your application which is awesome for projects with less dependencies. Graphs of projects with a lot of dependencies seems eventually more confusing than meaningful to me.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bk1agA1dq9zJfx2MxYR1bA.png" /><figcaption>Module dependency graph in <a href="https://webpack.github.io/analyse/">Webpack Analyzer</a></figcaption></figure><p>It also shows descriptive warnings and errors of your Webpack build as well as hints how to optimize your Webpack build.</p><p>Webpack Analyzer takes a <em>webpack-stats.json</em> file that Webpack generates with the following command:</p><pre>webpack --profile --json &gt; webpack-stats.json</pre><p>When you upload or Drag &amp; Drop this file into the Webpack Analyzer you’ll get the following overview page:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rKH5OC209hLRGySfBiNXfg.png" /><figcaption>Analysis results in <a href="https://webpack.github.io/analyse/">Webpack Analyzer</a></figcaption></figure><h3>Source Map Explorer</h3><p>The <a href="https://github.com/danvk/source-map-explorer">Source Map Explorer</a> is a tool I discovered just recently which helps me a lot getting a clear understanding of my minified <em>bundle.js</em> in terms of file size. It determines which file each byte in your minified bundle came from.</p><p>Unlike Webpack Visualizer and Webpack Analyzer it has to be installed globally on your machine via NPM:</p><pre>npm install -g source-map-explorer</pre><p>Or via Yarn:</p><pre>yarn global add source-map-explorer</pre><p>Now you have to provide your <em>bundle.js</em> and the corresponding Source Map file <em>bundle.js.map</em> to the tool to get a nice responsive treemap of your bundle:</p><pre>source-map-explorer bundle.js bundle.js.map</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HWqIHf_PaVcnRfiGwk44Bw.png" /><figcaption>Module treemap of Webpack bundle generated with <a href="https://github.com/danvk/source-map-explorer">Source Map Explorer</a></figcaption></figure><h3>Conclusion</h3><p>I think that there is no <em>“one analysis tool to rule them all”</em> since every tool gives a different perspective on your bundle.</p><p>I personally use the Webpack Visualizer a lot during development when I introduce new packages to the project. The circular graph gives an instant feedback about the proportions regarding size.</p><p>For a much more comprehensive overview regarding file size in the minified bundle I use Source Map Explorer.</p><p>The Webpack Analyzer has its use cases too but I don’t use it regularly.</p><p>Thanks for reading my first medium blog post 💚 Feel free to comment with suggestions and questions. I’d love to hear it!</p><p>Or follow me on Twitter if you like: <a href="https://twitter.com/joeclever"><strong>@joeclever</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7f6a8fe7195d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>