这个春季启动错误意味着什么?
2016-07-04 21:53:53 [restartedMain] ERROR o.s.boot.SpringApplication - Application startup failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name org.springframework.boot.autoconfigure.session.SessionAutoConfiguration$SessionRepositoryValidator': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: No session repository could be auto-configured, check your configuration (session store type is 'null')
Run Code Online (Sandbox Code Playgroud) 为什么我的弹簧测试设置失败,下面没有如此有用的错误消息?所有建议表示赞赏.
JUnit输出
java.lang.NoClassDefFoundError: org/junit/runners/model/MultipleFailureException
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.withAfterClasses(SpringJUnit4ClassRunner.java:188)
at org.junit.runners.ParentRunner.classBlock(ParentRunner.java:145)
at org.junit.runners.ParentRunner.run(ParentRunner.java:235)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run (SpringJUnit4ClassRunner.java:163)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: java.lang.ClassNotFoundException: org.junit.runners.model.MultipleFailureException
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 10 more
Run Code Online (Sandbox Code Playgroud)
控制台输出
INFO:org.springframework.test.context.support.DefaultTestContextBootstrapper - 从位置[META-INF/spring.factories]加载默认的TestExecutionListener类名:[org.springframework.test.context.web.ServletTestExecutionListener,org.springframework.test. context.support.DependencyInjectionTestExecutionListener,org.springframework.test.context.support.DirtiesContextTestExecutionListener,org.springframework.test.context.transaction.TransactionalTestExecutionListener,org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener] INFO:org.springframework.test. context.support.DefaultTestContextBootstrapper - 无法实例化TestExecutionListener [org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener].指定自定义侦听器类或使默认侦听器类(及其所需的依赖项)可用.违规类:[org/springframework/transaction/interceptor/TransactionAttribute] INFO:org.springframework.test.context.support.DefaultTestContextBootstrapper - 无法实例化TestExecutionListener [org.springframework.test.context.transaction.TransactionalTestExecutionListener].指定自定义侦听器类或使默认侦听器类(及其所需的依赖项)可用.违规类:[org/springframework/transaction/interceptor/TransactionAttributeSource] INFO:org.springframework.test.context.support.DefaultTestContextBootstrapper - 使用TestExecutionListeners:[org.springframework.test.context.web.ServletTestExecutionListener@76959acc,org.springframework. test.context.support.DependencyInjectionTestExecutionListener@57e603e6,org.springframework.test.context.support.DirtiesContextTestExecutionListener@3e0a1e1f]
这是目标片段
@Service
public class PipApps {
@Resource( name = …
Run Code Online (Sandbox Code Playgroud) 帮助 - 我还能做些什么来解决这个错误?org.springframework.web.HttpMediaTypeNotAcceptableException ::无法找到可接受的表示.
我认为我的项目已正确配置以处理json restful请求.在过去的几天里,我已阅读并应用各种建议无济于事.关于我应该采取哪些不同的做法,还有其他想法吗?
我使用的是Spring MVC 4.1.5和com.fasterxml 2.5.1.
我的pom.xml的一部分
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.5.1</version>
<type>bundle</type>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.5.1</version>
<type>bundle</type>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.5.1</version>
<type>bundle</type>
</dependency>
Run Code Online (Sandbox Code Playgroud)
这是我的web.xml的一部分
<!-- Creates the Spring Container shared by all Servlets and Filters -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Processes application requests -->
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring/appServlet/servlet-context.xml
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
Run Code Online (Sandbox Code Playgroud)
这是我的servlet-context.xml的一部分
<!-- Enables the Spring MVC @Controller programming model -->
<annotation-driven />
<!-- Handles HTTP …
Run Code Online (Sandbox Code Playgroud) 以下 thymeleaf 标记缺少什么:
<tr th:fragment="row" th:with="defaultAttrs='placeholder=\'' + ${placeholder} + '\''">
<td>
<input th:attr="${attrs ?: defaultAttrs}" />
</td>
...
</tr>
Run Code Online (Sandbox Code Playgroud)
来自
<th:block th:include="row::row(attrs='value=\'*{prodName}\', minLength=\'.{2, 16}\', required, title=\'starts with an alphabet 2 and 8\' placeholder=\'Product name\'')" />
Run Code Online (Sandbox Code Playgroud)
这是产生这个错误:
Could not parse as assignation sequence: "${attrs ?: defaultAttrs}"
Run Code Online (Sandbox Code Playgroud)
在一个不相关的注释中,不得不对异常消息进行双重考虑,以了解赋值而不是赋值一词的有趣用法
我想知道当我将 threadlocal.set() 设置为 32 个元素的集合时,它是如何没有存储数据的。ThreadLocal.get() 总是返回 null;并且对应的 FutureTask 对象有一个结果属性 = NullPointerException。知道为什么 ThreadLocal 无法存储集合项吗?
public class MyCallable<T> implements Callable<Collection<T>> {
public MyCallable( Collection<T> items ){
tLocal = new ThreadLocal<Collection<T>>();
tLocal.set( items ); //SETS NULL ALTHOUGH the PARAMETER CONTAINS 32 ITEMS
}
@Override
@SuppressWarnings("unchecked")
public Collection<T> call() throws Exception {
synchronized( lock ){
ArrayList<T> _items = new ArrayList<T>();
ArrayList<T> _e = ( ArrayList<T> ) tLocal.get(); //RETURNS NULL
for( T item : _e ){
_items = getPValue( item ));
}
return _items ; …
Run Code Online (Sandbox Code Playgroud) public class Foo<T extends Bar>{
private Class<T> _type;
public Foo( Class<T> _type ){
this._type = _type;
}
public Collection<T> hypothetical( List<T> items ){ //PROBLEMATIC
return dostuffWithItems( items );
}
}
Run Code Online (Sandbox Code Playgroud)
用法:
Foo<? extends ChildBar> foo = new Foo<ChildBar>( ChildBar.class );
List<ChildBar> items = ( List<ChildBar> ) foo.hypothetical( new ArrayList<ChildBar>() ); //COMPILER ERROR: The method hypothetical(List<capture#2-of ?>) in the type Foo<capture#2-of ?> is not applicable for the arguments (List<ChildBar>)
Run Code Online (Sandbox Code Playgroud)
编译器将接受
转换List<ChildBar> items
参数List<?>
或将hypothetical( List<T> items )
签名更改为 …
java ×4
spring ×4
spring-mvc ×3
spring-boot ×2
concurrency ×1
generics ×1
jackson ×1
json ×1
repository ×1
session ×1
testing ×1
thread-local ×1
thymeleaf ×1