我尝试反序列化包含null属性的对象并具有JsonMappingException.
我所做的:
String actual = "{\"@class\" : \"PersonResponse\"," +
" \"id\" : \"PersonResponse\"," +
" \"result\" : \"Ok\"," +
" \"message\" : \"Send new person object to the client\"," +
" \"person\" : {" +
" \"id\" : 51," +
" \"firstName\" : null}}";
ObjectMapper mapper = new ObjectMapper();
mapper.readValue(new StringReader(json), PersonResponse.class); //EXCEPTION!
Run Code Online (Sandbox Code Playgroud)
但是:如果扔掉"firstName = null"财产 - 一切正常!我的意思是传递下一个字符串:
String test = "{\"@class\" : \"PersonResponse\"," +
" \"id\" : \"PersonResponse\"," +
" \"result\" : \"Ok\"," + …Run Code Online (Sandbox Code Playgroud) 我刚刚完成了一个基于的Spring应用程序inMemoryAuthentication(),现在,经过验证,所有工作都完美无缺,我想使用JDBC身份验证.
我有三种类来处理与数据库的连接:
HibernateConfig,基于此博客文章中提供的代码.
DAO和Entity类,我的数据库中每个表一个(在当前状态下,我有三个:User,Role和User_Role)
还有一个UserService类,它实现了UserDetailsService.
我在互联网上阅读了一些文章,实际上他们都使用SecurityConfig类的以下配置:
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private DataSource dataSource;
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth
.jdbcAuthentication()
.dataSource(dataSource)
.usersByUsernameQuery(getUserQuery())
.authoritiesByUsernameQuery(getAuthoritiesQuery());
}
Run Code Online (Sandbox Code Playgroud)
对我来说有什么问题,因为我的项目中没有Datasource类.我目前的SecurityConfig是这样的:
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
public void configure(AuthenticationManagerBuilder auth) throws Exception {
auth
.jdbcAuthentication()
.usersByUsernameQuery(getUserQuery())
.authoritiesByUsernameQuery(getAuthoritiesQuery());
}
protected void configure(HttpSecurity http) throws Exception {
http
.csrf()
.disable()
.authorizeRequests()
.antMatchers("/css/**", "/fonts/**", "/image/**", "/js/**").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/spring/index").permitAll()
.loginProcessingUrl("/spring/login").permitAll()
.usernameParameter("login")
.passwordParameter("senha")
.successHandler(new …Run Code Online (Sandbox Code Playgroud) 我已经使用了一次又一次加载数据的单页.
正在使用相同的页面来加载数据; 即标题,照片和描述.你可以帮助我,以便我可以在其中应用滑动功能吗?我正在构建像Pulse News这样的应用程序,在刷卡功能上检查它.我已经在phonegap,HTML5,CSS3和JavaScript以及jQuery mobile中构建了它.
我知道如何刷页面,哪里有多个页面,但只有一个页面上动态加载数据,只有内容被更改,所以我应该如何添加滑动以便它可以在iPhone和Android上运行?
我注意到这个bug已经修复:
允许用户在本地模式下禁用Jetty Spark UI
但如何以编程方式禁用它?
它是由
sparkContext.setLocalProperty(?, ?)
Run Code Online (Sandbox Code Playgroud)
我检查了文档,但无法确定要设置的属性
http://spark.apache.org/docs/latest/configuration.html#spark-ui
我想迭代一个字符串的RDD并为每个字符串"做一些事情".输出应该是double[][].这是一个带有for循环的例子.我知道我需要使用(我认为)foreachJava RDD 的功能.但是,我不知道如何理解语法.文档不是特别有用.我没有Java 8.
这是一个例子,如果我可以使用常规for循环,我想做什么.
public class PCA {
public static void main(String[] args) {
SparkConf conf = new SparkConf().setAppName("PCA Example");
SparkContext sc = new SparkContext(conf);
RDD<String> data = sc.textFile("my/directory/my/dataset.txt", 0);
// here is the "type" of code I would like to execute
// 30 because I have 30 variables
double[][] vals = new double[data.count()][30];
double[] temp;
for (int i = 0; i < data.count(); i++) {
temp = splitStringtoDoubles(data[i]);
vals[i] = temp;
} …Run Code Online (Sandbox Code Playgroud) 我试图删除网格视图中的项目/文件.这些文件位于/data/my-image-folder/.文件立即被删除,但UI不会立即更新.这是我的代码:
imageFilePath = /data/<my-image-folder>/"file.jpg";
File file = new File(imageFilePath);
if (file.exists()) {
boolean deleted = file.delete();
sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED,Uri.parse(imageFilePath+ Environment.getExternalStorageDirectory())));
Run Code Online (Sandbox Code Playgroud)
getview代码:
View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View gridView;
if (convertView == null) {
gridView = new View(context);
// get layout from gridlayout.xml
gridView = inflater.inflate(R.layout.gridlayout, null);
// set value into textview
TextView textView = (TextView) gridView
.findViewById(R.id.grid_item_label);
textView.setText(fileList[position]);
System.out.println("value of fileList[position]" + fileList[0]);
// set image
ImageView imageThumbnail = (ImageView) …Run Code Online (Sandbox Code Playgroud) 我正在以这种方式导入svg(从服务器作为静态内容)
d3.xml("http://localhost:3000/mysvg.svg", "image/svg+xml", function(xml) {
var importedNode = document.importNode(xml.documentElement, true);
var mySvg = d3.select("#somediv").node().appendChild(importedNode);
Run Code Online (Sandbox Code Playgroud)
然后我试图遍历所有的svg路径并用它们做点什么
d3.selectAll("#somediv svg path").each(function(d, i) {
console.log(this, d, i);
});
}
Run Code Online (Sandbox Code Playgroud)
我得到的是这个问题
i 是从1到路径的数量,这是正确的.
d是undefined而不是被正确SVG路径元件.
this 是svg路径元素,就像这个
<path id="m021" fill="#00AAFF" d="M225.438,312.609c-0.665-1.084-1.062-1.691-2.368-1.963c-0.582-0.121-1.686-0.271-2.265-0.069 c-0.507,0.174-0.637,0.649-1.431,0.368c-0.934-0.33-0.665-1.272-0.71-2.104c-0.597-0.021-1.18,0-1.733,0.262 ...etc" ></path>
我期待d成为真正的svg路径,为什么不呢?
对我想做的事情有点了解可能有所帮助.
我有一个svg,我的城镇的每个区都有一条路.我想在每条路径的中心制作一些饼图.我现在没有数据,它将用于饼图.我想在路径上创建鼠标悬停功能,并在每条路径上添加一个小红圈(在将来的步骤中将成为饼图).
做这个的最好方式是什么?
我想要创建的是D3版本3.5.6中的可缩放,可刷新的时间轴.目前我没有使用D3的缩放行为,只有两个缩放按钮.我的问题如下:当单击一个按钮时,我更新比例并重新绘制轴和画笔.由于某种原因,画笔不会更新范围矩形和手柄,而只更新背景.我知道我实际上并没有更新.extent()刷子.但是,当规模改变时刷子应该更新吗?
这是代码的相关部分.其余的可以在这个小提琴中找到.
document.getElementById('in').addEventListener('click', zoom.bind(null, .1));
document.getElementById('out').addEventListener('click', zoom.bind(null, -.1));
function zoom(step) {
var offset;
zoomScale += step;
if(zoomScale < 1)
zoomScale -= step;
offset = (zoomScale * width - width) / 2;
// updating the scale
xScale
.range([-offset, width + offset]);
// redrawing the brush which doesn't seem to have effect I expected
brushGroup
.call(brush);
// redrawing the axis which works fine
xAxisGroup
.transition()
.call(xAxis);
}
Run Code Online (Sandbox Code Playgroud)
非常感谢!
我试图找出4向梯度填充的最佳模型.我的最新型号是这个小提琴:
<svg height="360" width="400" xmlns="http://www.w3.org/2000/svg" version="1.1">
<defs>
<clipPath id="C">
<path d="M 100 200 L 300 58 L 400 250 L 300 341 Z" />
</clipPath>
<radialGradient id="G1" cx="50%" cy="50%" r="50%" fx="50%" fy="50%">
<stop offset="0%" style="stop-color:rgb(255,0,0); stop-opacity:1" />
<stop offset="100%" style="stop-color:rgb(128,128,64); stop-opacity:0" />
</radialGradient>
<radialGradient id="G2" cx="50%" cy="50%" r="50%" fx="50%" fy="50%">
<stop offset="0%" style="stop-color:rgb(0,255,0); stop-opacity:1" />
<stop offset="100%" style="stop-color:rgb(128,128,64); stop-opacity:0" />
</radialGradient>
<radialGradient id="G3" cx="50%" cy="50%" r="50%" fx="50%" fy="50%">
<stop offset="0%" style="stop-color:rgb(0,0,255); stop-opacity:1" />
<stop offset="100%" style="stop-color:rgb(128,128,64); stop-opacity:0" /> …Run Code Online (Sandbox Code Playgroud) 是否可以执行以下操作?
List<Object o, Object p> listWithTwoObjects;
Run Code Online (Sandbox Code Playgroud)
我想从数据库中检索数据并将其保存到此列表中,具体就是以这种方式
Query query = "retrieve all posts and username, which this user posted";
List<Object o, Object p> userAndPost = query.getResultList();
Run Code Online (Sandbox Code Playgroud)
o是用户名,p是帖子.然后,我可以将其呈现给我的模板,并向其用户显示每个帖子.
我的问题是关于里面有两个对象的List.是否有可能,如果是的话,文件的方式和位置是什么?
我是Android的新手.任何人都可以告诉我如何RootView在Android中以编程方式更改布局的高度?我试过的代码如下
LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.sample, null);
view.getRootView().getLayoutParams().height = value;
Run Code Online (Sandbox Code Playgroud)
执行此操作后,我NullPointerException在上面的行中获得了一个.谁能帮我?提前致谢.
我首先要说的是我正在使用tweepy。我找到了一种过滤掉相同字符串的方法,但是我很难过滤掉相似的字符串。
我有两个句子字符串需要比较(Tweepy关键字=“ Donald Trump ”)
字串1: "Trump Administration Dismisses Surgeon General Vivek Murthy (http)PUGheO7BuT5LUEtHDcgm"
字串2: "Trump Administration Dismisses Surgeon General Vivek Murthy (http)avGqdhRVOO"
如您所见,它们相似但不相同。我需要找到一种方法来比较两者,并获取一个数字值,以确定是否应将第二条推文添加到第一条。我以为使用时有解决方案,SequenceMatcher()但总是打印出来0.0。我期望它会大于0.5。但是,Sequence Matcher似乎仅适用于一个单词字符串(如果我输入错误,请纠正我)。
现在您可能在想,“只是剪掉http部分”。这也不起作用,因为它无法解决@cars:xyz zyx和@trucks 这样的人鸣叫的名字:xyz zyx
有什么方法可以比较这两个文本吗?它应该很简单,但是由于某种原因,解决方案使我望而却步。我一周前才学过python。使用缩进来区分功能中的内容还是很奇怪。
如何从Arraylist带有索引位置的 a 中找到最大值?
ArrayList ar = new ArrayList();
ar.add(2); // position 0
ar.add(4); // position 1
ar.add(12); // position 2
ar.add(10); // position 3
ar.add(12); // position 4
String obj = Collections.max(ar);
int index = ar.indexOf(obj);
System.out.println("obj max value is " + obj + " and index position is " + index);
Run Code Online (Sandbox Code Playgroud)
上面的程序只是将输出作为第一个具有 value12和 index position 的max 对象返回2。
但我的实际输出应该是索引位置2和4(因为最大值12出现在两个索引位置)。