13-dic-2011 17.00.36 org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/server:/usr/lib/jvm/java-6-openjdk/jre/lib/amd64:/usr/lib/jvm/java-6-openjdk/jre/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib/jni:/lib:/usr/lib
13-dic-2011 17.00.36 org.apache.tomcat.util.digester.SetPropertiesRule begin
AVVERTENZA: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:Preventivi' did not find a matching property.
13-dic-2011 17.00.36 org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
13-dic-2011 17.00.36 org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8443"]
13-dic-2011 17.00.37 org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
13-dic-2011 17.00.37 org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 983 ms
13-dic-2011 17.00.37 org.apache.catalina.core.StandardService …
Run Code Online (Sandbox Code Playgroud) 我有一台带有16GB RAM的Linux服务器,并安装了docker主机.我想在其上部署一个Windows Server容器.可能吗?有人刚试过这个解决方案吗?
我在Java中编写了一个字符串,我在末尾插入了一个LF(换行符),如下所示:
String str = "......\n";
Run Code Online (Sandbox Code Playgroud)
我有一个数据集合,我需要为每个文档添加一个新字段.如果我运行查询以获取所有文档并且更新每个单个node.js都停止,则可能是内存泄漏
这是我的代码
var express = require('express');
var geocoderProvider = 'google';
var httpAdapter = 'http';
var People = require("./models/people").collection.initializeOrderedBulkOp();
var app = express();
var geocoder = require('node-geocoder').getGeocoder(geocoderProvider, httpAdapter, {});
app.get('/', function (req, res) {
People.find({}, function (err, docs) {
if (err) {
res.send(err);
}else{
docs.forEach( function (doc){
geocoder.geocode({address: doc.address, country: 'Italy', zipcode: doc.cap}, function(error, value) {
doc.loc.coordinates[0]=value[0].latitude;
doc.loc.coordinates[1]=value[0].longitude;
People.update({ _id: doc._id }, { $set: { loc: doc.loc }}, { multi: true }, function (error){
if(error){
console.error('ERROR!');
}
});
});
});
} …
Run Code Online (Sandbox Code Playgroud) 我有一个服务类,用春天写的,有一些方法.其中一个充当了如下的宁静消费者:
.....
HttpEntity request = new HttpEntity<>(getHeadersForRequest());
RestTemplate restTemplate = new RestTemplate();
String url = ENDPOINT_URL.concat(ENDPOINT_API1);
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url)
.queryParam("param1", parameter1);
ReportModel infoModel = null;
try{
infoModel = restTemplate.exchange(builder.toUriString(), HttpMethod.GET, request, ReportModel.class).getBody();
}catch (HttpClientErrorException | HttpServerErrorException e){
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
我想用来Mockito
模拟我的服务,但每个与restful服务器实例交互的方法都是一个新的RestTemplate.我要创建一个静态类来将它注入我的服务中?
我有一个本体文件,我可以获取其中的所有类(我正在使用 OWL-API)。好吧,我应该检索我的文件 .owl 中存在的每个类、数据属性和对象属性,有什么方法可以使用 OWL-API 获取它们吗?
我想测试一个保存到我的数据库中的循环。我已经在内存中设置了一个数据库并加载了我的场景。我有一个BasicInitTest
像这样命名的基本测试类
RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = CentralApplication.class)
@WebAppConfiguration
@Transactional
@Ignore
public class BasicInitTest {
.......
}
Run Code Online (Sandbox Code Playgroud)
我所有的测试类都扩展了这一点,并且每个测试类都有多种@Test
方法。特别是其中一个调用 a FooServiceImpl.iterateAndSave(List<FooModel>)
,它迭代一个列表并尝试保存单个对象。
FooServiceImpl.save(Foo)
保存方法由用 注释的方法执行@Transactional(propagation=Propagation.REQUIRED_NEW)
。此方法,在保存槽之前FooRepository.save(Foo)
,尝试查找对象来抛出异常或保存
@Transactional(propagation=Propagation.REQUIRED_NEW)
public Foo save(Foo foo) throws Exception {
Foo f = fooRepository.findById(foo.getId);
if(f) throw new Exception("ex");
return fooRepository.saveAndFlush(foo);
}
Run Code Online (Sandbox Code Playgroud)
就像上面的测试仍然在第一行服务暂停一样,相反,没有@Transactional(propagation=Propagation.REQUIRED_NEW)
,它可以工作。
我必须使用注释来@Transactional
防止异常,FooServiceImpl.iterateAndSave(List<FooModel>)
因为它有一个循环来迭代每个模型对象以执行某些操作,然后保存对象。
事实上,如果我删除注释,并且保存操作会出现异常,例如ConstraintViolationException
,当保存下一个对象时,我会收到此错误
HHH000099: an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of …
Run Code Online (Sandbox Code Playgroud) 我需要测试一个调用异步服务的控制器。
控制器代码
@RequestMapping(value = "/path", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public ResponseEntity<Result> massiveImport(HttpServletRequest request) {
try {
service.asyncMethod(request);
} catch (Exception e) {
e.printStackTrace();
return new ResponseEntity<>(new Result(e.getMessage()), HttpStatus.BAD_REQUEST);
}
return new ResponseEntity<>(new Result(saveContact.toString()), HttpStatus.OK);
}
Run Code Online (Sandbox Code Playgroud)
服务代码
@Async
public Future<Integer> asyncMethod(HttpServletRequest request) throws IllegalFieldValueException, Exception {
...
return new AsyncResult<>(value);
}
Run Code Online (Sandbox Code Playgroud)
测试代码
MvcResult result = getMvc().perform(MockMvcRequestBuilders.fileUpload("/path/")
.header("X-Auth-Token", accessToken)
.accept(MediaType.APPLICATION_JSON))
.andDo(print())
.andReturn();
Run Code Online (Sandbox Code Playgroud)
测试没问题。但是我会在关闭测试之前等待完成异步服务。
有没有办法做到这一点?
我的java类中有这个模型
@Document
public class Template {
private String type;
private String code;
@Version
Long version;
}
Run Code Online (Sandbox Code Playgroud)
我需要添加一个名为template的新字段,并将该字段映射为动态,换句话说,我会为这样的文档建模
{
_id: 'id'
type:'myType',
code:'myCode'
template:{
someFiled:[
{
subField1:'value1',
subField2:'value2'
},
{
sub1Field1:'1value1',
sub1Field2:'1value2'
}
.......................
],
otherField:[
{
otherField1:'value1',
otherField2:'value2'
}
],
.........
},
version:1000L
}
Run Code Online (Sandbox Code Playgroud)
有什么方法可以将字段注释为动态?
解决方案
@Document
public class Template {
private String type;
private String code;
private Map<String, Object> template;
@Version
Long version;
}
Run Code Online (Sandbox Code Playgroud) 我在localhost中设置了artifactory(我在设置我的服务器之前尝试使用localhost),但是当我在maven项目中使用这个repo时,我无法检索我的libs.有什么建议?
spring ×3
java ×2
mockito ×2
mongodb ×2
spring-boot ×2
artifactory ×1
async-await ×1
asynchronous ×1
docker ×1
eclipse ×1
junit ×1
maven ×1
mocking ×1
mongoose ×1
node.js ×1
ontology ×1
owl ×1
owl-api ×1
spring-data ×1
spring-mvc ×1
spring-test ×1
string ×1
tomcat7 ×1
transactions ×1
unit-testing ×1
window ×1