- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试按照 Spring 网站上的示例测试我的应用程序。
这些是我的依赖项:
dependencies {
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile("org.springframework.boot:spring-boot-starter-security")
compile('org.springframework.boot:spring-boot-starter-web')
compile("org.springframework.boot:spring-boot-starter-thymeleaf")
compile("org.thymeleaf.extras:thymeleaf-extras-springsecurity4")
runtime('org.springframework.boot:spring-boot-devtools')
runtime('com.h2database:h2')
runtime('mysql:mysql-connector-java')
compileOnly('org.projectlombok:lombok')
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile('org.springframework.security:spring-security-test')
}
这是测试类:
@RunWith(SpringRunner.class)
@SpringBootTest
@AutoConfigureMockMvc
public class ProductControllerTest {
@Autowired
private MockMvc mockMvc;
@Test
public void testHomePage() throws Exception {
this.mockMvc.perform(get("/")).andDo(print()).andExpect(status().isOk());
}
}
我收到错误:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
java.lang.IllegalStateException: Failed to load ApplicationContext
知道是什么原因造成的吗?我没有任何特定的配置文件,只有安全配置和 webconfig。
网络配置:
public class WebConfig implements WebMvcConfigurer {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/images/**", "/css/**", "/fragments/**")
.addResourceLocations("classpath:/static/images/", "classpath:/static/css/", "classpath:/fragments/");
}
}
最佳答案
输出中的以下行:
java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
告诉我们找不到类javax.xml.bind.JAXBException
。
正如 @Antot 提到的,将以下依赖项添加到您的 graddle 应该可以解决该问题:
compile('javax.xml.bind:jaxb-api:2.3.0')
对于使用 Maven 的用户,请使用以下命令:
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
关于java - 无法加载ApplicationContext(Spring Boot),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50140050/
我想在遗留应用程序中使用 Spring。 核心部分是一个类,我们称之为LegacyPlugin,它代表应用程序中的一种可插入部分。问题是这个类也是数据库连接器,并且用于创建许多其他对象,通常通过构造函
我有 3 个应用上下文: 负责启动 Jetty servlet 容器的全局上下文,从 main() 启动 jetty 中每个 webapp 的 applicationContext 父级(由 Spri
我通过以下代码在应用程序上下文中设置 applicationContext-dao.xml 和 applicationContext-service.xml。 proj
我正在尝试使用 Spring 运行 JUnit 测试,但控制台显示: 无法加载 ApplicationContext 错误。我正在使用 Maven 结构,并且在 src/main/resources
我的applicationContext.xml,webmvc-config.xml在WEB-INF/spring/applicationContext.xml 当我尝试以下操作时,它没有加载,我得到
我正在尝试从 WCSession 获取最新数据我不明白为什么即使我刚刚收到 didReceiveApplicationContext称呼。 更多细节可以直接在代码中获得: //Watch Code o
我正在尝试运行 mvn integration-test阶段,我得到 Failed to load ApplicationContext执行集成测试时出错(单元测试正确执行)。我正在使用 Spring
我在创建测试类时遇到问题。基本上我想测试执行网络调用的 View 模型类。使用 dagger 注入(inject)类网络组件需要上下文参数来检查连接,这是我的 View 模型: class MyVie
我有一个带有 Spring 插件的 struts2 Web 项目。 applicationContext.xml 位于 /WEB-INF/applicationContext.xml 我如何在我的类(
我在一个名为 Controller 的全局类中声明的全局变量有一个小问题,该全局类是从应用程序扩展的。 当我启动 Activity A 时,我在 Controller 中有一个包含 0 个项目的数组列
当我运行我的 spring 集成 junit 类时,我遇到了异常。 这是我的类(class) @RunWith(SpringJUnit4ClassRunner.class) @ContextConfi
我是 java EE spring boot 的新手,我想我会开始一个小项目来掌握一些东西,我目前遇到如上所述的错误 failed to load ApplicationContext 我是不知道为什
我只能在 Spring (3.0.5) jdbc 应用程序(在 Oracle 11.2 上运行)中获取 Activity 的编程事务,当txAdvice指向从应用程序上下文调用的实际方法(mainTe
在servet类中,可以通过这种方式获取spring ApplicationContext ApplicationContext ctx = WebApplicationContextUtils.ge
抱歉,如果我的术语不正确,我是 C# 的新手。我正在尝试使用 ApplicationContext 文件来存储 mysql conn 值,如 dbname、用户名、密码。带有 mysql conn 字
我正在尝试在所有 ContextXXXEvent 上使用 ContextEventListener我为每种事件类型创建了一个监听器,如下所示(ContextRefreshedEvent 是一个示例):
我的应用程序有一个 application-context.xml。现在我将 ApplicationContext 实例化为: ApplicationContext context = new Cla
我正在开发一个 spring 3 web 服务应用程序,我正在尝试从我的 servlett.xml 文件加载 ApplicationContext 以用于一个简单的测试用例,但它不起作用。 Appli
在我的应用程序完成后,我想关闭 spring 上下文。 相关代码有一个 ApplicationContext 引用,但我找不到 close 方法。 最佳答案 贬低你的ApplicationContex
我在尝试为 kotlin 多平台自定义上下文时遇到了这个问题 Actual typealias 'ApplicationContext' has no corresponding expected d
我是一名优秀的程序员,十分优秀!