我必须将Json对象与具有Date的java对象绑定.我的Json上的日期格式如下:
2013-01-04T10:50:26 + 0000
我正在使用GsonBulder如下:
Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").create();
Run Code Online (Sandbox Code Playgroud)
但我得到以下例外:
The RuntimeException could not be mapped to a response, re-throwing to the HTTP container
com.google.gson.JsonSyntaxException: 2013-01-04T10:50:26+0000
at com.google.gson.internal.bind.DateTypeAdapter.deserializeToDate(DateTypeAdapter.java:81)
.....
Caused by: java.text.ParseException: Unparseable date: "2013-01-04T10:50:26+0000"
at java.text.DateFormat.parse(DateFormat.java:337)
at com.google.gson.internal.bind.DateTypeAdapter.deserializeToDate(DateTypeAdapter.java:79)
Run Code Online (Sandbox Code Playgroud)
我正在尝试用Gson加载这个请求:
https://graph.facebook.com/me?fields=id,username,email,link,updated_time&access_token=accessToken
Run Code Online (Sandbox Code Playgroud)
而且回应是
{"id":"12345","username":"myusername","email":"myemail\u0040yahoo.it","link":"http:\/\/www.facebook.com\/mysusername","updated_time":"2013-01-04T10:50:26+0000"}
Run Code Online (Sandbox Code Playgroud) 当我运行ubuntu时,我安装的tomcat服务器自动运行,我必须手动关闭它.我希望tomcat不要在启动时自动启动.如何在启动时禁用tomcat的启动?
我在eclipse中开发了一个Spring JPA项目,可以访问存储在mysql服务器中的数据.现在我需要在Spring @ MVC项目中导入这个项目.所以
当我尝试在tomcat服务器上运行应用程序时,我收到一个错误.我似乎缺少spring-beans库,但正如你在pom配置中看到的那样,我导入了它.这是错误日志:
INFO: Initializing Spring root WebApplicationContext
INFO : org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization started
INFO : org.springframework.web.context.support.XmlWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Mon Feb 06 22:26:12 CET 2012]; root of context hierarchy
INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/spring/root-context.xml]
INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [META-INF/spring/app-context.xml]
INFO : org.springframework.context.annotation.ClassPathBeanDefinitionScanner - JSR-330 'javax.inject.Named' annotation found and supported for component …Run Code Online (Sandbox Code Playgroud) 我有一个使用Spring和Spring安全性构建的Web应用程序,允许用户通过Facebbok注册ether或创建帐户,在这两种情况下都会创建一个Web应用程序帐户.所以2种注册方法如下::
现在我正在为移动应用程序创建一个休息服务,它需要身份验证.我使用基本的http auth来访问Web服务.
我现在的问题是如何使用spring security在我的Web应用程序中登录用户?
我的想法是:
你认为这种流程是否安全?你有其他想法吗?
先感谢您
我正在尝试使用 terraform 创建一个简单的 appengine 应用程序。
首先,我使用 gcloud cli 创建了所有基本资源。这里我列出我执行过的命令:
export PROJECT=ProjectName
export TF_VAR_billing_account=xxxxxx-xxxxxx-xxxxxx
export TF_VAR_project=${PROJECT}-terraform
export TF_CREDS=./${PROJECT}-terraform.json
gcloud projects create ${TF_VAR_project} \
--set-as-default
gcloud beta billing projects link ${TF_VAR_project} \
--billing-account ${TF_VAR_billing_account}
######################################################################################
##### Create the Terraform service account
######################################################################################
gcloud iam service-accounts create terraform \
--display-name "Terraform admin account"
gcloud iam service-accounts keys create ${TF_CREDS} \
--iam-account terraform@${TF_VAR_project}.iam.gserviceaccount.com
gcloud projects add-iam-policy-binding ${TF_VAR_project} \
--member serviceAccount:terraform@${TF_VAR_project}.iam.gserviceaccount.com \
--role roles/editor
gcloud projects add-iam-policy-binding ${TF_VAR_project} \
--member serviceAccount:terraform@${TF_VAR_project}.iam.gserviceaccount.com \
--role roles/storage.admin
gcloud …Run Code Online (Sandbox Code Playgroud) 我有一个用 spring mvc 开发的 Web 应用程序,为了持久性,我使用 JPA(休眠实现),我想向该应用程序添加一个 CRUD GUI。
你知道一些允许我在我的项目中从 JPA 实体生成 CRUD GUI 的框架吗?
在此先感谢您的帮助
我正在开发一个具有REST API的Web应用程序.目前,Api在服务器端受到弹簧安全保护,具有表单登录身份验证.最近我还添加了spring social以允许访问facebook和twitter,这一切都有效.因此,必须注册用户才能访问某个端点.
现在我必须构建一个必须访问REST API的移动应用程序,我想知道我应该使用什么策略.
我看到facebook有一个android/ios sdk允许在移动端进行身份验证.因此,一旦用户在移动设备上进行了身份验证,我应该向我的服务器发出请求,那么我应该如何验证服务器端的用户访问资源?
如果您认为这不是一个好的解决方案,您可以给我一个如何解决这个问题的建议吗?
通过实体管理器,我试图将实体保存在数据库中,但我无法保存它。这是我的配置。
我有这个实体:
@Entity
@Table(name = "User")
public class UserModel implements Serializable, ModelItem {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
@Column(nullable = false)
private String username;
@Column(nullable = false)
private String password;
@Column(nullable = false)
private String name;
private String surname;
private String notes;
private String cellphone;
@Column(nullable = false)
private String email;
private Boolean enabled;
//get and set methods
.....
}
Run Code Online (Sandbox Code Playgroud)
和我的导入 bean 执行持久性操作:
@Repository
public class ImportServiceImpl implements ImportService {
@PersistenceContext …Run Code Online (Sandbox Code Playgroud) 我正在尝试构建一个尝试验证xml的路由,如果一切正确,则必须拆分此文件,否则抛出异常并且必须执行其他操作.所以我做了以下事情:
from("file:"+fileOutboxTransformed+"?preMove=inprogress&move="+backupFolderTransformed+"/"+labelMessageType+"_${date:now:yyyyMMddHHmmssSSS}-${file:name.noext}.${file:ext}")
.log(LoggingLevel.INFO, "Got transformed file and sending it to jms queue: "+queue)
.doTry()
.to("validator:classpath:"+validator)
.split(xPathMessageTypeSplit)
.to("jms:"+queue+"?jmsMessageType=Text")
.doCatch(ValidationException.class)
.log(LoggingLevel.INFO, "Validation Exception for message ${body}")
.to("xslt:classpath:"+transformationsErrorAfter)
.split(xPathNotificationSplit)
.to("file:"+fileOutboxInvalid+"?fileName=${file:name.noext}-${date:now:yyyyMMddHHmmssSSS}.err2")
.end();
Run Code Online (Sandbox Code Playgroud)
但它不编译(如果我不使用拆分然后它编译和工作),错误是:
The method doCatch(Class<ValidationException>) is undefined for the type ExpressionNode
Run Code Online (Sandbox Code Playgroud)
所以我尝试了以下内容
from("file:"+fileOutboxTransformed+"?preMove=inprogress&move="+backupFolderTransformed+"/"+labelMessageType+"_${date:now:yyyyMMddHHmmssSSS}-${file:name.noext}.${file:ext}")
.log(LoggingLevel.INFO, "Got transformed file and sending it to jms queue: "+queue)
.doTry()
.to("direct:validate")
.doCatch(ValidationException.class)
.log(LoggingLevel.INFO, "Validation Exception for message ${body}")
.to("xslt:classpath:"+transformationsErrorAfter)
.split(xPathNotificationSplit)
.to("file:"+fileOutboxInvalid+"?fileName=${file:name.noext}-${date:now:yyyyMMddHHmmssSSS}.err2")
.end();
from("direct:validate")
.to("validator:classpath:"+validator)
.to("direct:split_message");
from("direct:split_message")
.split(xPathMessageTypeSplit)
.to("jms:"+queue+"?jmsMessageType=Text");
Run Code Online (Sandbox Code Playgroud)
这次我得到重复端点的错误
org.apache.camel.FailedToStartRouteException: Failed to start route route312 because of Multiple …Run Code Online (Sandbox Code Playgroud) 我有一个Spring Boot项目,必须启动角度水疗.资源文件夹的结构如下:

在templates/src文件夹中有我从控制器开始的index.html文件:
@RequestMapping("/")
String index() {
return "src/index";
}
Run Code Online (Sandbox Code Playgroud)
通过这种方式,我成功启动了index.html,但所有的反应都在:
未正确加载.所以我添加了配置:
@Configuration
public class WebConfig extends WebMvcAutoConfiguration.WebMvcAutoConfigurationAdapter {
private static final Logger LOGGER = Logger.getLogger(WebConfig.class);
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler( "/js/**")
.addResourceLocations( "/templates/src/js/");
}
}
Run Code Online (Sandbox Code Playgroud)
但是我仍然无法加载所有需要的资源,因为我得到了404

我不明白我做错了什么.
这里也是index.html:
<!DOCTYPE html>
<html lang="en" data-ng-app="app">
<head>
<meta charset="utf-8" />
<title>Angular version | Angulr</title>
<meta name="description" content="Angularjs, Html5, Music, Landing, 4 in 1 ui kits package" />
<meta name="keywords" content="AngularJS, angular, bootstrap, admin, dashboard, panel, app, charts, …Run Code Online (Sandbox Code Playgroud) 我正在尝试设置Junit测试来测试JPA配置.该课程如下:
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
public class OrderPersistenceTests {
@Autowired
public JpaDaoRole dr;
@Transactional
public void test1() throws Exception {
Role r = new Role();
r.setIdRole(18);
r.setDescription("description");
dr.persist(r);
Role r1=dr.findById(r.getIdRole());
assertEquals(r.getIdRole(), r1.getIdRole());
}
}
Run Code Online (Sandbox Code Playgroud)
这里也是我的app-context配置:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<description>Example configuration to get you started.</description>
<!-- Generic -->
<context:annotation-config />
<tx:annotation-driven transaction-manager="transactionManager" />
<context:component-scan base-package="com.windy.spring" />
<!-- JPA -->
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
<tx:annotation-driven />
<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> …Run Code Online (Sandbox Code Playgroud) 当我运行简单的 Junit 测试来测试 Jpa/Dao 配置时,出现以下错误:
2012-01-30 23:24:19,606 INFO [org.springframework.test.context.TestContextManager] - <@TestExecutionListeners is not present for class [class com.windy.spring.OrderPersistenceTests]: using defaults.>
2012-01-30 23:24:19,738 INFO [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] - <Loading XML bean definitions from class path resource [com/windy/spring/OrderPersistenceTests-context.xml]>
2012-01-30 23:24:19,895 INFO [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] - <Loading XML bean definitions from class path resource [META-INF/spring/app-context.xml]>
2012-01-30 23:24:20,111 INFO [org.springframework.context.support.GenericApplicationContext] - <Refreshing org.springframework.context.support.GenericApplicationContext@36b8bef7: startup date [Mon Jan 30 23:24:20 CET 2012]; root of context hierarchy>
2012-01-30 23:24:20,266 INFO [org.springframework.beans.factory.support.DefaultListableBeanFactory] - <Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@291946c2: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,jpaDaoRole,jpaDaoUser,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor#0,org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0,entityManagerFactory,dataSource,transactionManager]; root …Run Code Online (Sandbox Code Playgroud) 我正在使用spring boot 1.1.5构建一个MongoDb rest应用程序.我创建了一个存储库:
@RepositoryRestResource(collectionResourceRel = "SourceProductV1Repository", path = "SourceProductV1Repository")
public interface SourceProductV1Repository extends MongoRepository<SourceProductV1Model, String> {
public List<SourceProductV1Model> findByUser (@Param("user") MongoUser user);
}
Run Code Online (Sandbox Code Playgroud)
我定义了一个转换器将String转换为MongoUser(转换器在spring上下文中正确注册):
@Component
public class String2MongoUserConverter implements Converter<String, MongoUser>{
private static final Log LOGGER = LogFactory.getLog(String2MongoUserConverter.class.getName());
@Override
public MongoUser convert(String s) {
return null;
}
}
Run Code Online (Sandbox Code Playgroud)
所以当我尝试访问时 http://localhost:8080/SourceProductV1Repository/search/findByUser?user=test
我收到以下错误:
org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type java.lang.String to type @org.springframework.data.repository.query.Param com.ddelizia.model.MongoUser
at org.springframework.core.convert.support.GenericConversionService.handleConverterNotFound(GenericConversionService.java:291)
at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:177)
at org.springframework.data.rest.core.invoke.ReflectionRepositoryInvoker.prepareParameters(ReflectionRepositoryInvoker.java:265)
at org.springframework.data.rest.core.invoke.ReflectionRepositoryInvoker.invokeQueryMethod(ReflectionRepositoryInvoker.java:230)
at org.springframework.data.rest.webmvc.RepositorySearchController.executeQueryMethod(RepositorySearchController.java:236)
at org.springframework.data.rest.webmvc.RepositorySearchController.executeSearch(RepositorySearchController.java:146)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native …Run Code Online (Sandbox Code Playgroud) java ×6
spring ×6
jpa ×3
facebook ×2
apache-camel ×1
autostart ×1
crud ×1
dao ×1
gcloud ×1
gson ×1
junit ×1
login ×1
spring-boot ×1
spring-data ×1
spring-mvc ×1
terraform ×1
thymeleaf ×1
tomcat ×1
ubuntu ×1