{"@attributes":{"version":"2.0"},"channel":{"title":"Springboot on \u00d6zkan Pakdil Software Engineer","link":"https:\/\/ozkanpakdil.github.io\/categories\/springboot\/","description":"Recent content in Springboot on \u00d6zkan Pakdil Software Engineer","image":{"title":"\u00d6zkan Pakdil Software Engineer","url":"https:\/\/ozkanpakdil.github.io\/images\/papermod-cover.png","link":"https:\/\/ozkanpakdil.github.io\/images\/papermod-cover.png"},"generator":"Hugo -- 0.148.2","language":"en","copyright":"\u00d6zkan Pakdil","lastBuildDate":"Sat, 18 May 2024 00:00:30 +0000","item":[{"title":"Spring boot 3 RestClient and RestTemplate logging http requests and response","link":"https:\/\/ozkanpakdil.github.io\/posts\/my_collections\/2024\/2024-05-18-http-logging\/","pubDate":"Sat, 18 May 2024 00:00:30 +0000","guid":"https:\/\/ozkanpakdil.github.io\/posts\/my_collections\/2024\/2024-05-18-http-logging\/","description":"<p>In Spring boot(SB) 2 the configuration was different, now in SB3 we need to configure the rest client differently. Before SB3 there was RestTemplate now there is new Rest api coming in spring world. Find more details <a href=\"https:\/\/spring.io\/blog\/2023\/07\/13\/new-in-spring-6-1-restclient\">here<\/a>.<\/p>\n<p>Adding the required dependency which will do the real http logging here.<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;\"><code class=\"language-gradle\" data-lang=\"gradle\"><span style=\"display:flex;\"><span>    implementation <span style=\"color:#e6db74\">&#39;org.apache.httpcomponents.client5:httpclient5:5.3.1&#39;<\/span>\n<\/span><\/span><\/code><\/pre><\/div><p>The big difference is properties configuration, it is changed and not documented on spring site<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;\"><code class=\"language-properties\" data-lang=\"properties\"><span style=\"display:flex;\"><span><span style=\"color:#a6e22e\">logging.level.org.apache.hc.client5.http.wire<\/span><span style=\"color:#f92672\">=<\/span><span style=\"color:#e6db74\">DEBUG<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#a6e22e\">logging.level.org.apache.hc.client5.http<\/span><span style=\"color:#f92672\">=<\/span><span style=\"color:#e6db74\">DEBUG<\/span>\n<\/span><\/span><\/code><\/pre><\/div><p>Using only &ldquo;wire&rdquo; will give request\/response dump. And that extra http=DEBUG will give connection and more debug log, find it at the end of the page.<\/p>"},{"title":"Using sqlite with h2 console","link":"https:\/\/ozkanpakdil.github.io\/posts\/my_collections\/2023\/2023-10-10-sqlite-flyway-h2console\/","pubDate":"Tue, 10 Oct 2023 00:00:30 +0000","guid":"https:\/\/ozkanpakdil.github.io\/posts\/my_collections\/2023\/2023-10-10-sqlite-flyway-h2console\/","description":"<p>Sometimes we(developers\/programmers) may need to see database tables in tree and run some select, insert quickly on the db, H2 console is the best tool in spring boot to reach database on dev environment.<\/p>\n<p>And I saw a question about &ldquo;Using Flyway with SQLite database in spring boot&rdquo;, I have been using liquibase around 5 years but I have not tried flyway before, <strong>learning opportunity<\/strong>.<\/p>\n<p>So I preapred an example with gradle spring boot, sqlite and h2 console and answered the <a href=\"https:\/\/stackoverflow.com\/a\/76917474\/175554\">question<\/a>.<\/p>"},{"title":"Printing running sqls in logs with spring boot 3 and hibernate 6","link":"https:\/\/ozkanpakdil.github.io\/posts\/my_collections\/2023\/2023-04-08-springboot-3-hibernate-6-print-sql\/","pubDate":"Sat, 08 Apr 2023 11:42:30 +0000","guid":"https:\/\/ozkanpakdil.github.io\/posts\/my_collections\/2023\/2023-04-08-springboot-3-hibernate-6-print-sql\/","description":"<p>In application.properties<\/p>\n<pre tabindex=\"0\"><code>logging.level.org.hibernate=info\nlogging.level.org.hibernate.SQL=debug\nlogging.level.org.hibernate.orm.jdbc.bind=trace\nlogging.level.org.hibernate.stat=debug\nlogging.level.org.hibernate.SQL_SLOW=info\nlogging.level.org.hibernate.cache=debug\n<\/code><\/pre><p>will make print all sqls and bindings with it like below<\/p>\n<pre tabindex=\"0\"><code>2023-04-08T09:31:54.232+01:00 DEBUG 164224 --- [           main] org.hibernate.SQL                        : insert into &#34;address&#34; (&#34;city&#34;, &#34;line1&#34;, &#34;post_code&#34;, &#34;id&#34;) values (?, ?, ?, ?)\n2023-04-08T09:31:54.232+01:00 TRACE 164224 --- [           main] org.hibernate.orm.jdbc.bind              : binding parameter [1] as [VARCHAR] - [Glasgow]\n2023-04-08T09:31:54.232+01:00 TRACE 164224 --- [           main] org.hibernate.orm.jdbc.bind              : binding parameter [2] as [VARCHAR] - [apt:0]\n2023-04-08T09:31:54.232+01:00 TRACE 164224 --- [           main] org.hibernate.orm.jdbc.bind              : binding parameter [3] as [VARCHAR] - [G0]\n2023-04-08T09:31:54.232+01:00 TRACE 164224 --- [           main] org.hibernate.orm.jdbc.bind              : binding parameter [4] as [BIGINT] - [28]\n<\/code><\/pre>"},{"title":"Printing running sqls with P6spy in spring boot 3 and hibernate 6","link":"https:\/\/ozkanpakdil.github.io\/posts\/my_collections\/2023\/2023-04-08-springboot-3-hibernate-6-print-sql-with-p6spy\/","pubDate":"Sat, 08 Apr 2023 00:00:00 +0000","guid":"https:\/\/ozkanpakdil.github.io\/posts\/my_collections\/2023\/2023-04-08-springboot-3-hibernate-6-print-sql-with-p6spy\/","description":"<p>in build.gradle<\/p>\n<pre tabindex=\"0\"><code>implementation &#39;p6spy:p6spy:3.9.1&#39;\n<\/code><\/pre><p>In application.properties<\/p>\n<pre tabindex=\"0\"><code>spring.datasource.url=jdbc:p6spy:h2:mem:testdb\nspring.datasource.driverClassName=com.p6spy.engine.spy.P6SpyDriver\n<\/code><\/pre><p>and in spy.properties<\/p>\n<pre tabindex=\"0\"><code>driverlist=org.h2.Driver\nappender=com.p6spy.engine.spy.appender.StdoutLogger\nlogMessageFormat=com.p6spy.engine.spy.appender.CustomLineFormat\ncustomLogMessageFormat=%(currentTime)|%(executionTime)|%(sqlSingleLine)\n<\/code><\/pre><p>With this configuration application logs will appear in console. like below<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;\"><code class=\"language-SQL\" data-lang=\"SQL\"><span style=\"display:flex;\"><span><span style=\"color:#ae81ff\">2023<\/span><span style=\"color:#f92672\">-<\/span><span style=\"color:#ae81ff\">04<\/span><span style=\"color:#f92672\">-<\/span><span style=\"color:#ae81ff\">08<\/span>T12:<span style=\"color:#ae81ff\">14<\/span>:<span style=\"color:#ae81ff\">54<\/span>.<span style=\"color:#ae81ff\">237<\/span><span style=\"color:#f92672\">+<\/span><span style=\"color:#ae81ff\">01<\/span>:<span style=\"color:#ae81ff\">00<\/span> DEBUG <span style=\"color:#ae81ff\">178209<\/span> <span style=\"color:#75715e\">--- [nio-8080-exec-4] o.s.w.f.CommonsRequestLoggingFilter      : Before request [GET \/byname\/name1]\n<\/span><\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#75715e\"><\/span><span style=\"color:#ae81ff\">1680952494240<\/span><span style=\"color:#f92672\">|<\/span><span style=\"color:#ae81ff\">0<\/span><span style=\"color:#f92672\">|<\/span><span style=\"color:#66d9ef\">select<\/span> c1_0.<span style=\"color:#e6db74\">&#34;id&#34;<\/span>,c1_0.<span style=\"color:#e6db74\">&#34;last_name&#34;<\/span>,c1_0.<span style=\"color:#e6db74\">&#34;name&#34;<\/span> <span style=\"color:#66d9ef\">from<\/span> <span style=\"color:#e6db74\">&#34;customer&#34;<\/span> c1_0 <span style=\"color:#66d9ef\">where<\/span> c1_0.<span style=\"color:#e6db74\">&#34;name&#34;<\/span><span style=\"color:#f92672\">=<\/span><span style=\"color:#e6db74\">&#39;name1&#39;<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#ae81ff\">1680952494242<\/span><span style=\"color:#f92672\">|<\/span><span style=\"color:#ae81ff\">0<\/span><span style=\"color:#f92672\">|<\/span><span style=\"color:#66d9ef\">select<\/span> a1_0.<span style=\"color:#e6db74\">&#34;customer_id&#34;<\/span>,a1_1.<span style=\"color:#e6db74\">&#34;id&#34;<\/span>,a1_1.<span style=\"color:#e6db74\">&#34;city&#34;<\/span>,a1_1.<span style=\"color:#e6db74\">&#34;line1&#34;<\/span>,a1_1.<span style=\"color:#e6db74\">&#34;post_code&#34;<\/span> <span style=\"color:#66d9ef\">from<\/span> <span style=\"color:#e6db74\">&#34;customer_addresses&#34;<\/span> a1_0 <span style=\"color:#66d9ef\">join<\/span> <span style=\"color:#e6db74\">&#34;address&#34;<\/span> a1_1 <span style=\"color:#66d9ef\">on<\/span> a1_1.<span style=\"color:#e6db74\">&#34;id&#34;<\/span><span style=\"color:#f92672\">=<\/span>a1_0.<span style=\"color:#e6db74\">&#34;addresses_id&#34;<\/span> <span style=\"color:#66d9ef\">where<\/span> a1_0.<span style=\"color:#e6db74\">&#34;customer_id&#34;<\/span><span style=\"color:#f92672\">=<\/span><span style=\"color:#ae81ff\">2<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#ae81ff\">1680952494244<\/span><span style=\"color:#f92672\">|<\/span><span style=\"color:#ae81ff\">0<\/span><span style=\"color:#f92672\">|<\/span><span style=\"color:#66d9ef\">select<\/span> o1_0.<span style=\"color:#e6db74\">&#34;customer_id&#34;<\/span>,o1_1.<span style=\"color:#e6db74\">&#34;id&#34;<\/span>,o1_1.<span style=\"color:#e6db74\">&#34;create_time&#34;<\/span>,o1_1.<span style=\"color:#e6db74\">&#34;full_price&#34;<\/span>,o1_1.<span style=\"color:#e6db74\">&#34;items&#34;<\/span>,o1_1.<span style=\"color:#e6db74\">&#34;update_time&#34;<\/span>,o1_1.<span style=\"color:#e6db74\">&#34;version&#34;<\/span> <span style=\"color:#66d9ef\">from<\/span> <span style=\"color:#e6db74\">&#34;customer_orders&#34;<\/span> o1_0 <span style=\"color:#66d9ef\">join<\/span> <span style=\"color:#e6db74\">&#34;order&#34;<\/span> o1_1 <span style=\"color:#66d9ef\">on<\/span> o1_1.<span style=\"color:#e6db74\">&#34;id&#34;<\/span><span style=\"color:#f92672\">=<\/span>o1_0.<span style=\"color:#e6db74\">&#34;orders_id&#34;<\/span> <span style=\"color:#66d9ef\">where<\/span> o1_0.<span style=\"color:#e6db74\">&#34;customer_id&#34;<\/span><span style=\"color:#f92672\">=<\/span><span style=\"color:#ae81ff\">2<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#ae81ff\">1680952494246<\/span><span style=\"color:#f92672\">|<\/span><span style=\"color:#ae81ff\">0<\/span><span style=\"color:#f92672\">|<\/span><span style=\"color:#66d9ef\">select<\/span> b1_0.<span style=\"color:#e6db74\">&#34;customer_id&#34;<\/span>,b1_1.<span style=\"color:#e6db74\">&#34;id&#34;<\/span>,b1_1.<span style=\"color:#e6db74\">&#34;create_time&#34;<\/span>,b1_1.<span style=\"color:#e6db74\">&#34;items&#34;<\/span>,b1_1.<span style=\"color:#e6db74\">&#34;update_time&#34;<\/span>,b1_1.<span style=\"color:#e6db74\">&#34;version&#34;<\/span> <span style=\"color:#66d9ef\">from<\/span> <span style=\"color:#e6db74\">&#34;customer_baskets&#34;<\/span> b1_0 <span style=\"color:#66d9ef\">join<\/span> <span style=\"color:#e6db74\">&#34;basket&#34;<\/span> b1_1 <span style=\"color:#66d9ef\">on<\/span> b1_1.<span style=\"color:#e6db74\">&#34;id&#34;<\/span><span style=\"color:#f92672\">=<\/span>b1_0.<span style=\"color:#e6db74\">&#34;baskets_id&#34;<\/span> <span style=\"color:#66d9ef\">where<\/span> b1_0.<span style=\"color:#e6db74\">&#34;customer_id&#34;<\/span><span style=\"color:#f92672\">=<\/span><span style=\"color:#ae81ff\">2<\/span>\n<\/span><\/span><\/code><\/pre><\/div><p>If required user can change the log format like described <a href=\"https:\/\/github.com\/p6spy\/p6spy\/blob\/master\/src\/main\/assembly\/individualFiles\/spy.properties#L101\">here<\/a>, <a href=\"https:\/\/github.com\/ozkanpakdil\/spring-examples\/tree\/master\/h2-spring-transactions-p6spy\">here<\/a> is working example project.<\/p>\n<p>P6spy is good for development but should not be used in production, for production every database has their own monitoring logging solution which will show what sql is running from which user.<\/p>"},{"title":"Spring-boot VS Quarkus VS Golang","link":"https:\/\/ozkanpakdil.github.io\/posts\/my_collections\/2020\/12-17-quarkus-vs-springboot-vs-golang\/","pubDate":"Thu, 17 Dec 2020 00:00:00 +0000","guid":"https:\/\/ozkanpakdil.github.io\/posts\/my_collections\/2020\/12-17-quarkus-vs-springboot-vs-golang\/","description":"Springboot VS Quarkus VS Golang"},{"title":"Spring-boot vs Quarkus","link":"https:\/\/ozkanpakdil.github.io\/posts\/my_collections\/2019\/12-26-quarkus-vs-springboot\/","pubDate":"Thu, 26 Dec 2019 00:00:00 +0000","guid":"https:\/\/ozkanpakdil.github.io\/posts\/my_collections\/2019\/12-26-quarkus-vs-springboot\/","description":"Springboot VS Quarkus"}]}}