cnblogs/dcrenl/Spring Boot创建完项目运行Cannot determine embedded database driver class for database type NONE.html

15 lines
1.1 KiB
HTML
Raw Normal View History

2024-09-24 12:43:01 +08:00
<p>spring boot 创建项目引用mybatis后直接运行会提示</p>
<blockquote>
<p>Cannot determine embedded database driver <span class="hljs-keyword">class <span class="hljs-keyword">for database <span class="hljs-class"><span class="hljs-keyword">type <span class="hljs-title">NONE</span></span></span></span></span></p>
</blockquote>
<p>因为springboot启动时会自动注入数据源</p>
<p>使用@SpringBootApplication注解排除注入即可</p>
<div class="cnblogs_code">
<pre>@SpringBootApplication(exclude={DataSourceAutoConfiguration.<span style="color: #0000ff;">class</span><span style="color: #000000;">})
</span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span><span style="color: #000000;"> Application {
</span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span><span style="color: #000000;"> main(String[] args){
SpringApplication.run(Application.</span><span style="color: #0000ff;">class</span><span style="color: #000000;">, args);
}
}</span></pre>
</div>
<p>&nbsp;</p>