我使用C++的经验预先添加了字符串类,所以我在某些方面重新开始.
我正在为我的类定义我的头文件,并希望为url创建一个静态常量.我这样做的方法如下:
#include <string>
class MainController{
private:
static const std::string SOME_URL;
}
const std::string MainController::SOME_URL = "www.google.com";
Run Code Online (Sandbox Code Playgroud)
但这在链接期间给了我一个重复的定义.
我怎么能做到这一点?
我正在尝试构建一个全新的Spring Framework 4.0项目,没有所有神奇的gradle东西,但只是踢它老派.
我在这里按照教程:http://spring.io/guides/tutorials/data/并取得了一些成功.我只是停留在这一点上.
/**
*
*/
package com.corrisoft.air.db.integration;
import javax.persistence.EntityManager;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.TransactionConfiguration;
import org.springframework.transaction.annotation.Transactional;
import com.corrisoft.air.db.JPAConfiguration;
import static com.corrisoft.air.db.fixture.JPAAssertions.assertTableExists;
import static com.corrisoft.air.db.fixture.JPAAssertions.assertTableHasColumn;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = { JPAConfiguration.class })
@Transactional
@TransactionConfiguration(defaultRollback = true)
public class PersonMappingIntegrationTests {
@Autowired
EntityManager manager;
@Test
public void thatItemCustomMappingWorks() throws Exception {
assertTableExists(manager, "PERSONS");
assertTableHasColumn(manager, "PERSONS", "FIRST_NAME");
assertTableHasColumn(manager, "PERSONS", "LAST_NAME");
}
}
Run Code Online (Sandbox Code Playgroud)
当我运行此单元测试时,我得到以下堆栈跟踪:
SEVERE: Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@68c884e] to …Run Code Online (Sandbox Code Playgroud) 我想排序string[]在递减的方式.到目前为止,我所做的是以下代码:
let values = ["Saab", "Volvo", "BMW"]; // example
values.sort();
values.reverse();
Run Code Online (Sandbox Code Playgroud)
它正在工作,但我想弄清楚是否有更好的方法来做到这一点.
我有一个存储应用程序上下文信息的应用程序 应用程序上下文信息在MyApp类中的活动之间共享,该类扩展了Application类.
我正在为我的活动编写单元测试,我想检查当用户单击活动中的按钮时,应用程序状态将发生变化.像这样的东西:
@Override
public void onClick(View pView) {
((MyApp)getApplicationContext()).setNewState();
}
Run Code Online (Sandbox Code Playgroud)
问题是我不知道如何模拟该应用程序上下文.我使用ActivityUnitTestCase作为测试用例库.当我调用setApplication时,它会更改Activity类的mApplication成员的值,但不会更改应用程序上下文的值.我也尝试过setActivityContext,但它似乎不对(它不是应用程序上下文而是活动上下文)并且它在startActivity中触发断言).
所以问题是 - 如何模拟getApplicationContext()?
我的C++程序中出现以下错误:
1> c:\users\thom\documents\cworkspace\barnaby\barnaby\timezone.cpp(14) : see reference to class template instantiation 'std::map<_Kty,_Ty>' being compiled
Run Code Online (Sandbox Code Playgroud)
这在错误堆栈中有点下降,但指向这行代码:
static std::map<const std::string, Timezone> timezoneMap;
Run Code Online (Sandbox Code Playgroud)
原因是Timezone有一个相当复杂的构造函数,但没有默认的构造函数.这是错误的一部分:
c:\program files\microsoft visual studio 10.0\vc\include\map(215): error C2512: 'Timezone::Timezone' : no appropriate default constructor available
Run Code Online (Sandbox Code Playgroud)
1> c:\ program files\microsoft visual studio 10.0\vc\include\map(210):同时编译类模板成员函数'Timezone&std :: map <_Kty,_Ty> :: operator [](const std :: basic_string <_Elem,_Traits,_Ax>&)'
我的问题是,为什么?为什么地图试图构造时区对象?如果我总是将完全成形的物体放入我的地图中,为什么还需要呢?特别是,当我初始化地图时为什么会出现这个错误?
我在堆栈溢出中找到了三个条目:
javax.validation.ValidationException:无法找到默认提供程序
javax.validation.ValidationException:无法找到默认提供程序
并且所有三个人都说将hibernate验证器添加到类路径中.当我这样做并仍然得到相同的错误时我该怎么办?
1301 [main] ERROR org.springframework.web.servlet.DispatcherServlet - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/db.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Unable to get the default Bean Validation factory
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:567)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:631)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:588)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:645)
at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:508)
at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:449)
at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:133)
at javax.servlet.GenericServlet.init(GenericServlet.java:241) …Run Code Online (Sandbox Code Playgroud) 我正试图通过我的角度应用程序进行api调用.我想要做的是使用命令参数向api发送一个post请求.我已经做了很多服务器端测试以及完成传出请求,$_POST而且body数据永远不存在.因此,我很确定这个问题存在于这段代码中.
public post(cmd: string, data: object): Observable<any> {
const params = new URLSearchParams();
params.set('cmd', cmd);
const options = new RequestOptions({
headers: this.getAuthorizedHeaders(),
responseType: ResponseContentType.Json,
params: params,
body: data,
withCredentials: false
});
console.log('Options: ' + JSON.stringify(options));
return this.http.post('http://t2w.dev/index.php', data, options)
.map(this.handleData)
.catch(this.handleError);
}
Run Code Online (Sandbox Code Playgroud)
我尝试了许多不同的JSON结构,data但这是我尝试发送的核心:
{
"Username": "No thanks",
"Password": "Donno"
}
Run Code Online (Sandbox Code Playgroud)
this.handleData并且this.handleError是一种将数据和错误作为参数的方法,并返回我想要的内容.
api设置为记录任何通过$_POST哪些工作正常运行请求从任何地方,但我的角度应用程序.到目前为止我做了什么:
URLSearchParams.控制台输出
RequestOptions选项:{"method":null,"headers":{"Content-Type":["application/json"],"Accept":["application/json"],"X-CLIENT-ID":[" 380954038 "]," X-CLIENT-SECRET ":[" 5BgqRO9BMZ4iocAXYjjnCjnO7fHGN59WP8BTRZ5f "]},"身体":"{}", …
自2.5以来,我没有跟上spring框架的所有变化.我正在寻找一个4.0的示例应用程序,它具有基本的骨架应用程序,其中hibernate使用控制器和服务以4.0方式完成.
我用Google搜索并查看了弹簧网站,我认为在过去的一年左右,这个网站已经变得更糟了.谁能帮我吗?
我在如何为选择对话框添加选项方面遇到了困难.
我正在阅读的Adobe笔记在这里:CQ.form.Selection
向下滚动options : Object[]/String将显示两种方法来引用选项,通过对象或字符串提供所述选择.我正在尝试使用对象方法.他们提供的格式示例就足够了.
[
{
value: "pink", // all types except "combobox"
text: "Pink",
qtip: "Real Pink" // "select" and "combobox"
}
]
Run Code Online (Sandbox Code Playgroud)
但是,CRXDE Lite不允许我在添加新属性时选择或键入Object,这是我不知所措的地方.还有另一种输入复杂价值的方法吗?
我们在应用程序中创建了一个LocationListener.有时,手机会进入"GPS Gap",只是停止报告位置数据.我们已经观看了一段时间,似乎从这个状态移动它的唯一的事情是重新启动手机.
我把它们连接起来以便关闭日志并发现:
02-18 13:35:43.671 703 948 I LocationManagerService: handleLocationChanged for android.uid.system:1000, Provider: passive
02-18 13:35:43.671 703 948 I LocationManagerService: handleLocationChanged for com.google.uid.shared:10040, Provider: passive
02-18 13:35:43.671 703 948 I LocationManagerService: handleLocationChanged for com.google.uid.shared:10040, Provider: passive
02-18 13:35:43.671 703 948 D LocationManagerService: dropping location (blacklisted): com.google.android.apps.maps matches com.google.
Run Code Online (Sandbox Code Playgroud)
查看上面提到的源文件,它只是检查它创建的黑名单,如果它在黑名单中,则显然不会报告该点.
查看代码和上面的代码看起来像是阻止com.google的位置数据,但我不知道为什么.
我搜查了一下,没有发现任何事情,并希望得到一些帮助.
java ×4
spring ×3
android ×2
c++ ×2
hibernate ×2
aem ×1
angular ×1
angular-http ×1
arrays ×1
class ×1
definition ×1
gps ×1
jpa ×1
junit ×1
spring-4 ×1
stl ×1
typescript ×1
unit-testing ×1
visual-c++ ×1