这与一个较老的问题非常相似,但解决方案对我不起作用.
我有一个WAR包.
在 web.xml
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:application-context.xml</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
Run Code Online (Sandbox Code Playgroud)
在 application-context.xml
<bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>classpath:social.properties</value>
</property>
</bean>
Run Code Online (Sandbox Code Playgroud)
但得到这个:
org.springframework.beans.factory.BeanInitializationException:无法加载属性; 嵌套异常是java.io.FileNotFoundException:无法打开ServletContext资源[/social.properties]
我查了WAR包- .xml和.properties文件都在/WEB-INF/classes
.properties文件是in src/main/resources和.xmlin src/main/java(在默认包中)和maven在默认包中正确传输它们(我认为)WEB-INF/classes
有谁知道为什么我会得到这个例外?谢谢.
编辑:我只是想补充一点,JUnit测试正确(我的意思是他们加载他们应该的东西social.properties)但是在运行应用程序时它会忽略我的classpath:前缀
让我来描述我想要做的事情.我正在构建一个真正的动态ng指令来构建基于数据数组和提供的配置对象的表.我想知道的是如何根据范围内的对象动态分配属性.假设我在某个范围内有一个对象,例如:
$scope.inputs.myInput = {
type : "number",
size : 3,
min : 0,
...
}
Run Code Online (Sandbox Code Playgroud)
等等,在我的模板中的某个地方
<tr><td>other stuff</td><td><input {{assign the attributes somehow}} /></td></tr>
Run Code Online (Sandbox Code Playgroud)
结果将是:
<tr><td>other stuff</td><td><input type='number' size='3' min='0' ... /></td></tr>
Run Code Online (Sandbox Code Playgroud)
这有点可能吗?
我尝试了什么:目前,我设法为每一行的输入数组中的每个项创建一个输入,我可以分配一个类型type={{type}}但是html属性可以对每种类型的输入元素有所不同,我认为分配属性是不好的元素"硬编码"的方式,并被困在这里.
提前感谢您的任何反馈!
有没有办法通过 apollo 异常处理程序手动运行异常?
我 90% 的应用程序都在 GraphQL 中,但仍然有两个 REST 模块,我想统一处理异常的方式。
因此,GQL 查询会抛出标准的 200 错误数组,其中包含消息、扩展名等。
{
"errors": [
{
"message": { "statusCode": 401, "error": "Unauthorized" },
"locations": [{ "line": 2, "column": 3 }],
"path": [ "users" ],
"extensions": {
"code": "INTERNAL_SERVER_ERROR",
"exception": {
"response": { "statusCode": 401, "error": "Unauthorized" },
"status": 401,
"message": { "statusCode": 401, "error": "Unauthorized" }
}
}
}
],
"data": null
}
Run Code Online (Sandbox Code Playgroud)
其中 REST 使用 JSON 抛出真正的 401:
{
"statusCode": 401,
"error": "Unauthorized"
}
Run Code Online (Sandbox Code Playgroud)
那么我可以简单地捕获异常并以 Apollo …