如何在TypeScript或Javascript中处理类型转换?
假设我有以下TypeScript代码:
module Symbology {
export class SymbolFactory {
createStyle( symbolInfo : SymbolInfo) : any {
if (symbolInfo == null)
{
return null;
}
if (symbolInfo.symbolShapeType === "marker") {
// how to cast to MarkerSymbolInfo
return this.createMarkerStyle((MarkerSymbolInfo) symbolInfo);
}
}
createMarkerStyle(markerSymbol : MarkerSymbolInfo ): any {
throw "createMarkerStyle not implemented";
}
}
}
Run Code Online (Sandbox Code Playgroud)
哪里SymbolInfo是基类.如何从处理类型转换SymbolInfo到MarkerSymbolInfo以打字稿或Javascript?
我只修改了spring boot配置,并遇到了
@ConditionalOnProperty(prefix = "spring.social.", value = "auto-connection-views")
Run Code Online (Sandbox Code Playgroud)
从 org.springframework.boot.autoconfigure.social.TwitterAutoConfiguration
@Bean(name = { "connect/twitterConnect", "connect/twitterConnected" })
@ConditionalOnProperty(prefix = "spring.social.", value = "auto-connection-views")
public View twitterConnectView() {
return new GenericConnectionStatusView("twitter", "Twitter");
}
Run Code Online (Sandbox Code Playgroud)
我不明白这个注释的目的.我想这可能只有在存在属性值时才能使用bean(例如"spring.social","auto-connection-views").
如何在TypeScript中实现Regexp?
我的例子:
var trigger = "2"
var regex = new RegExp('^[1-9]\d{0,2}$', trigger); // where I have exeption in Chrome console
Run Code Online (Sandbox Code Playgroud) 如果我可以${project.build.sourceDirectory}用来引用源目录,我可以用什么来引用"resources"目录?
看着超级pom,看起来${project.build.resources.resource.directory}会起作用,但事实并非如此...
IntelliJ(v11.1)通常在Java类旁边显示的图标是带有C的蓝色圆圈.但对于我的一个类,此图标的左上角有一个小"x".这个特殊的类在另一个类的包中,它只有蓝色圆圈中的常用C.
如果它很重要,我正在使用Mac.
有问题的类是AlertsHandler.

我打电话返回XML REST服务,并使用Jaxb2Marshaller元帅我的课(例如Foo,Bar等).所以我的客户端代码如下所示:
HashMap<String, String> vars = new HashMap<String, String>();
vars.put("id", "123");
String url = "http://example.com/foo/{id}";
Foo foo = restTemplate.getForObject(url, Foo.class, vars);
Run Code Online (Sandbox Code Playgroud)
当服务器端的查找失败时,它返回404以及一些XML.我最终UnmarshalException因为无法读取XML而被抛出.
Caused by: javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"exception"). Expected elements are <{}foo>,<{}bar>
Run Code Online (Sandbox Code Playgroud)
回复的主体是:
<exception>
<message>Could not find a Foo for ID 123</message>
</exception>
Run Code Online (Sandbox Code Playgroud)
如何配置,RestTemplate以便在404发生时RestTemplate.getForObject()返回null?
Future.get()在任务完成后多次调用Java时,Java的行为如何?它会返回相同的结果吗?或者,ExecutionException如果计算失败,会一次又一次地抛出相同的异常吗?我在文档中找不到任何关于它的东西!
@Autowired通过构造函数按类型查找bean.如何使用自动装配的注释将bean按名称注入构造函数?我有2个相同类型的bean但我需要根据bean名称将它注入另一个相同类的构造函数.我该怎么做?
XML:
<bean id="A" class="com.Check"/>
<bean id="B" class="com.Check"/>
Run Code Online (Sandbox Code Playgroud)
Java的:
Class C {
private Check check;
@Autowired
public C(Check check){
this.check = check
}
}
Run Code Online (Sandbox Code Playgroud)
当我这样做时,我得到一个异常告诉我,我有2个相同类型的bean检查,但它要求只有一个这种类型的bean.如何通过构造函数注入将bean id="B"注入此类C?
在我的applicationContext.xml我已经提到autowire="byType".我byName只需要在这个特定的类休息时自动装配它只需要通过类型自动装配
我想知道mapDispatchToProps今天是否还有一点使用.我正在研究redux文档教程(构建一个todo列表),其中VisibleTodoList描述如下:
import { connect } from 'react-redux'
import { toggleTodo } from '../actions'
import TodoList from '../components/TodoList'
const getVisibleTodos = (todos, filter) => {
switch (filter) {
case 'SHOW_ALL':
return todos
case 'SHOW_COMPLETED':
return todos.filter(t => t.completed)
case 'SHOW_ACTIVE':
return todos.filter(t => !t.completed)
}
}
const mapStateToProps = (state) => {
return {
todos: getVisibleTodos(state.todos, state.visibilityFilter)
}
}
const mapDispatchToProps = (dispatch) => {
return {
onTodoClick: (id) => {
dispatch(toggleTodo(id))
}
}
} …Run Code Online (Sandbox Code Playgroud) 我UntypedActor需要从中读取可配置的值application.conf.以下行有效,但似乎有点长啰嗦.
public class FooUntypedActor extends UntypedActor {
private final long bar = context().system().settings().config().getLong("foo.bar");
// other stuff
}
Run Code Online (Sandbox Code Playgroud)
这是在Akka中获取可配置值的正确方法吗?
我应该说清楚我正在使用Java API.
java ×4
spring ×2
typescript ×2
akka ×1
annotations ×1
casting ×1
future ×1
javascript ×1
jaxb ×1
maven ×1
react-native ×1
react-redux ×1
reactjs ×1
redux ×1
regex ×1
rest ×1
spring-3 ×1
spring-boot ×1