我正在尝试将Spring Web应用程序部署到Tomcat 7.0.24,但它在启动时挂起,最后一行显示为
INFO: Deploying web application archive /usr/local/apps/tomcat-7.0.42/webapps/server-webapp.war
Apr 4, 2014 1:38:28 PM org.apache.catalina.core.ApplicationContext log
INFO: Spring WebApplicationInitializers detected on classpath: [com.verical.marketplace.init.MarketplaceWebAppInitializer@6a05fdf]
Apr 4, 2014 1:38:30 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
Run Code Online (Sandbox Code Playgroud)
我最近升级到Spring 4.0.2并通过注释使用客户WebApplicationInitializer.在升级之前,我使用Spring 3和纯XML配置,它运行得很好.我的web.xml文件如下所示:
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd
http://java.sun.com/xml/ns/javaee/web-common_3_0.xsd"
version="3.0">
<!-- Define the mime mappings -->
<mime-mapping>
<extension>xsd</extension>
<mime-type>text/xml</mime-type>
</mime-mapping>
<!-- Define the welcome file list -->
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<!-- Define the default session timeout value -->
<session-config>
<session-timeout>240</session-timeout>
<cookie-config> …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Spring 的 RestTemplate 功能发送 POST 请求,但在发送对象时遇到问题。这是我用来发送请求的代码:
RestTemplate rt = new RestTemplate();
MultiValueMap<String,Object> parameters = new LinkedMultiValueMap<String,Object>();
parameters.add("username", usernameObj);
parameters.add("password", passwordObj);
MyReturnObj ret = rt.postForObject(endpoint, parameters, MyRequestObj.class);
Run Code Online (Sandbox Code Playgroud)
我还有一个日志拦截器,所以我可以调试输入参数,它们几乎是正确的!目前,usernameObj和passwordObj参数显示如下:
{"username":[{"testuser"}],"password":[{"testpassword"}]}
Run Code Online (Sandbox Code Playgroud)
我希望它们看起来如下:
username={"testuser"},password={"testpassword"}
Run Code Online (Sandbox Code Playgroud)
假设usernameObj和passwordObj是已编组为 JSON 的 Java 对象。
我究竟做错了什么?
我知道这个问题被问了好几次,我已经阅读了所有的答案,但我仍然有问题.基本上,我正在尝试设置OAuth2 RestTemplate但是在尝试使用RestTemplate发出getForEntity请求时收到错误(就像许多其他人一样):
org.springframework.security.oauth2.client.resource.UserRedirectRequiredException: A redirect is required to get the users approval
Run Code Online (Sandbox Code Playgroud)
希望有人可以告诉我我做错了什么.这是我的配置类:
@Configuration
@EnableOAuth2Client
public class OAuth2Configuration
{
@Autowired
private OAuth2ClientContext oauth2Context;
@Value("${test.oauth.key}")
private String key;
@Value("${test.oauth.secret}")
private String secret;
@Value("${test.auth.url}")
private String authUrl;
@Value("${test.token.url}")
private String tokenUrl;
/**
* Returns an OAuth2 protected resource connection to test
*
* @return the oauth2 protected resource
*/
@Bean
public OAuth2ProtectedResourceDetails test()
{
// Create a new authorization code resource details object
AuthorizationCodeResourceDetails details = new AuthorizationCodeResourceDetails();
// Set the information …Run Code Online (Sandbox Code Playgroud)