How to initiate NamedParameterJdbcTemplate for H2 Query?
<p>I am working on an application using java 8 + Spring 4. I'm removing the Spring DI requirement so the application can run without Spring DI.</p>
<p>I will use Springs <code>JdbcTemplate</code> and <code>NamedParameterJdbcTemplate</code> for database operations. I'm using these templates as we would use any other feature/.jar in the java application.</p>
<p>While I'm removing all the <code>@Autowired</code> and other spring-related annotations (and making them through constructor now)</p>
<p>Spring version is this way:</p>
<pre><code>public class H2Dao {
    private NamedParameterJdbcTemplate t;
    @Autowired
    public H2Dao(@Qualifier(&quot;H2JdbcTemplate&quot;) NamedParameterJdbcTemplate t) {
        this.t=t;
    }
}
</code></pre>
<p><code>application-context.xml</code> has below code for this:</p>
<pre><code>&lt;jdbc:embedded-database id=&quot;h2DataSource&quot; type=&quot;H2&quot;&gt;
        &lt;jdbc:script location=&quot;classpath:db/sql/h2.init.sql&quot; /&gt;
    &lt;/jdbc:embedded-database&gt;

&lt;bean id=&quot;H2JdbcTemplate&quot; class=&quot;org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate&quot;&gt;
        &lt;constructor-arg ref=&quot;h2DataSource&quot; name=&quot;dataSource&quot; /&gt;
    &lt;/bean&gt;
</code></pre>
<p><code>h2.init.sql</code> file has below code:</p>
<pre><code>CREATE ALIAS ROWNUM_OVER FOR &quot;com.xx.xxxx.h2.H2Function.rowNumOver&quot;;
CREATE ALIAS DBO_UFUN_ADDDATETIME FOR &quot;com.xx.xxxx.h2.H2Function.addDateTime&quot;;
</code></pre>
<p>My Question is, How can I write the same code in non-spring version that does not use <code>application-context.xml</code> for DI. I want to use constructor <code>H2Dao</code> with <code>NamedParameterJdbcTemplate</code> as parameter. how to instantiate <code>NamedParameterJdbcTemplate</code> to pass <code>H2Dao</code> constructor?</p>