我的项目中有一个主修班。
@SpringBootApplication
@EnableOAuth2Sso
public class App
{
public static void main(String[] args) throws Exception {
SpringApplication.run(App.class, args);
}
@Bean public RequestContextListener requestContextListener(){
return new RequestContextListene
我在Spring项目(spring-server)中创建了Spring契约存根。想要调用这个存根的客户端不是Spring项目,也不是Spring项目。如果我在客户机中运行以下代码:
@RunWith(SpringRunner.class)
@SpringBootTest
@AutoConfigureStubRunner(ids = {"uk.co.hadoopathome:spring-server:+:stubs:8093"},
stubsMode = StubRunnerProperties.StubsMode.LOCAL)
public class Con
遵循本教程,我有一个基于Spring Boot的独立(非web)应用程序:
我跳过hikaricp部分,因为我直接使用mysql。该应用程序运行良好,能够查询、调用RESTful web服务...然而,我不能让junit测试工作,一直得到这个错误:
java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=...) with your test
at org.spr
我正在尝试在Eclipse中对我的Spring项目进行单元测试。我遇到的问题是我的@Autowire被忽视了。
@SpringBootTest
public class ValidateRepositoryTest {
private static final String CREATE_TBLVALIDATE_SQL_SCRIPT = "scripts/create/validate.sql";
private static final String DROP_TBLVALIDATE_SQL_SCRIPT = "scripts/drop/validat
我在运行Junit测试时有问题,我有错误:
java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=...) with your test
at org.springframework.util.Assert.state(Assert.java:73)
我怎么看,Spring找不到我的测试类。我有多个maven模块,在我的A模块中我有SpringBootAppli
这是我第一次问问题,所以请引导我克服我可能犯的错误。
我第一次使用Intellij和Spring -also来制作web应用程序的后端部分。
它编译了ok,但是一旦我尝试运行它,就会得到以下错误:
2018-02-27 17:00:33.526 INFO 4308 --- [ main] g.n.e.s.k.KidspirationApplication : Starting KidspirationApplication on mini-me with PID 4308 (started by Orestis in C:\Users\Orestis\Des
如何让spring评估varargs并有条件地运行beans?
@SpringBootConfiguration
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class);
}
}
@Service
@Order(1) //run if no vararg is given
public class Job1 implements ApplicationRunner {
}
@Service
@Order(2) //
我试着为我的项目写一个简单的测试(这是我的第一个测试,所以不要苛刻地评判我),但我的测试失败了,我得到了一个错误:
java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:132)
at org.springframework.t
我想编写必须使用Spring Framework和自定义JPA提供程序的集成测试。我认为简单的答案是创建一个测试类,并按如下方式注释它:
@RunWith(SpringRunner.class)
@SpringBootTest
public class Test { ...
希望所有的缺省自动配置都能自动完成。但它不是错误是:
java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(cl
在SpringBoot 1.4中的控制器测试中,我面临着集成测试的问题。下面的片段将显示项目结构的清晰概念:
类ExchangeControllerIT :
public class ExchangeControllerIT extends AbstractSpringControllerIT {
// class under test
@Autowired
private ExchangeController exchangeController;
@Autowired
private OAuth2RestTemplat
我试着研究使用Spring引导的aws。我发现了很多关于SpringBootRequestHandler实现的教程,但是现在这个库被认为是不推荐的。因此,我试图找到一个解决方案,并找到一个:。该解决方案声明将@SpringBootApplication类用于lambdas定义,因此我创建了一个非常简单的项目,该项目将数据保存并接收到/从DynamoDB:
package com.example;
@SpringBootApplication
public class DynamoDbApplication {
public static void main(String[] ar
我正在努力解决@Autowired注释问题。我以这段代码为例,但是在我的测试类中,Java说我的自动字段是null。当我使用AnnotationConfigApplicationContext时,测试就通过了,但不适用于@Autowired。当我在测试类的前面添加注释@SpringBootTest时,@Autowired字段,然后IntelliJ说“无法自动更新,没有找到‘库’类型的bean”。我在我的根项目中包含了这个特定的模块。
@Repository
public class LibraryDbController {
public void saveData(){
我有课:
@Service
public class A {
@Value("${a.b.c}")
private String abc;
public void foo() {
sout(abc);
}
}
我有考试课:
@SpringBootTest
@SpringBootConfiguration
@RunWith(SpringRunner.class)
@TestPropertySource(locations = "classpath:application.yml")
public class TestA {
@Val
在添加第二个测试类之后,我在jUnit测试期间出错。
java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=...) with your test
我添加了...so (classes=...)部分添加到SpringBootTest注释中,测试运行良好。
@RunWith(SpringRunner.class)
@SpringBootTest(classes = {my
在为我的项目创建Jar文件之前,我试图在Spring项目上进行清理和安装,但是我遇到了这个错误
java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=...) with your test
我是Spring的新手,从未真正使用过它的测试功能。因此,我的测试类在很大程度上是默认的,它最初是如何用项目创建的。
我的考试课
package com.Alex.demo;
因此,我有两个注释A和B来自现有的java库,它们实现了AOP。
他们两人都做了我们班必须做的事情,我需要把他们按这个顺序排列(A在B之前):
public class MyClass{
@A(parameter="par")
@B(value="key")
public void method(){
}
}
是否可以将第三个注释C定义为两者的组合?所以最终我会得到:
public class MyClass{
@C(parameter="par", value="key")