Spring Boot GS:ConnectionFactory的ComponentScan和ClassNotFoundException [英] Spring Boot GS: ComponentScan and ClassNotFoundException for ConnectionFactory
问题描述
我在玩Spring Boot入门指南,但是自动配置失败,我得到了:
I'm playing sur the Spring Boot getting started guide but the auto configuration fails and I get:
java.lang.ClassNotFoundException: javax.jms.ConnectionFactory
似乎是由于Application类的位置.应该在哪里?在顶级软件包(src/main/java)还是特定软件包中?
It seems it's due to the location of the Application class. Where should it be located? At the top-level package (src/main/java) or in a specific package?
推荐答案
您的Application
类应放在特定的程序包中,而不应放在默认(顶级)程序包中.例如,将其放在com.example
中,并将所有应用程序代码放入此程序包或诸如com.example.foo
和com.example.bar
的子程序包中.
Your Application
class should be placed in a specific package and not in the default (top-level) package. For example, put it in com.example
and place all your application code in this package or in sub-packages like com.example.foo
and com.example.bar
.
将Application
类放在默认包中,即直接放在src/main/java
中不是一个好主意,并且几乎可以肯定会导致您的应用程序无法启动.如果这样做,您应该看到以下警告:
Placing your Application
class in the default package, i.e. directly in src/main/java
isn't a good idea and it will almost certainly cause your application to fail to start. If you do so, you should see this warning:
** WARNING ** : Your ApplicationContext is unlikely to start due to a @ComponentScan of the default package.
这篇关于Spring Boot GS:ConnectionFactory的ComponentScan和ClassNotFoundException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!