我正在尝试java.lang.function.Function
在我的java 8代码库中使用a ,但我在Intellij中不断收到以下错误.
使用API记录为@since 1.6+此检查查找在其文档中具有@since标记的方法的所有用法.当在较新的SDK版本下执行开发作为生产的目标平台时,这可能很有用
我似乎有正确的项目和编译器设置
项目设置:(文件 - >项目结构)
Project Settings -> Project -> Project SDK = Java 1.8
Project Settings -> Project -> Project Language Level = 8 - Lambdas, Type Annotations etc
Run Code Online (Sandbox Code Playgroud)
编译器设置:(文件 - >设置)
Build, Execution, Deployment -> Compiler -> Java Compiler -> Project Bytecode Version : 1.8
Build, Execution, Deployment -> Compiler -> Java Compiler -> Per module Bytecode Version -> Target Bytecode Version : 1.8
Run Code Online (Sandbox Code Playgroud)
问题是什么?
我有一个Web应用程序,我有一个典型的问题,它需要不同环境的不同配置文件.某些配置作为JNDI数据源放置在应用程序服务器中,但某些配置保留在属性文件中.
因此,我想使用Spring配置文件功能.
我的问题是我没有运行测试用例.
context.xml中:
<context:property-placeholder
location="classpath:META-INF/spring/config_${spring.profiles.active}.properties"/>
Run Code Online (Sandbox Code Playgroud)
测试用例:
@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
TestPreperationExecutionListener.class
})
@Transactional
@ActiveProfiles(profiles = "localtest")
@ContextConfiguration(locations = {
"classpath:context.xml" })
public class TestContext {
@Test
public void testContext(){
}
}
Run Code Online (Sandbox Code Playgroud)
问题似乎是加载配置文件的变量未解决:
Caused by: java.io.FileNotFoundException: class path resource [META-INF/spring/config_${spring.profiles.active}.properties] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:157)
at org.springframework.core.io.support.PropertiesLoaderSupport.loadProperties(PropertiesLoaderSupport.java:181)
at org.springframework.core.io.support.PropertiesLoaderSupport.mergeProperties(PropertiesLoaderSupport.java:161)
at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.postProcessBeanFactory(PropertySourcesPlaceholderConfigurer.java:138)
... 31 more
Run Code Online (Sandbox Code Playgroud)
应使用@ActiveProfile
注释设置当前配置文件.因为它是一个测试用例,我将无法使用web.xml
.如果可能的话,我也想避免运行时选项.测试应按原样运行(如果可能).
如何正确激活配置文件?是否可以使用context.xml设置配置文件?我可以在test-context.xml中声明实际调用普通上下文的变量吗?
是否有用于字符串连接的JPA concat运算符?
我知道有一个JPA CONCAT
函数,但它用于连接多个字符串很难看.
CONCAT(CONCAT(CONCAT(cola,colb),colc),cold)
Run Code Online (Sandbox Code Playgroud)
像甲骨文||
这样的供应商提供其他类似微软的产品 +
.是否有标准的JPA连接运算符,以便我可以创建一个类似的查询
cola || colb || colc || cold
Run Code Online (Sandbox Code Playgroud)
我尝试+
将openjpa与SQL Server一起使用,但它似乎是无效的JPQL.我在oracle参考中找不到关于这样的运算符的任何内容.
我想在页面上显示简单的文本,因此我想返回Content-Type
as text/plain
.
使用下面的代码,我在页面上看到纯文本,但返回Content-Type
仍然是text/html
.
我怎样才能解决这个问题?
注意:我正在使用带有Spring MVC的Tiles.返回的"m.health"指向一个tile def,它映射到一个health.jsp,它只包含下面的1行.
更新说明:我无法控制HTTP标头请求中的Content-Type
或Accept
值.text/plain
无论发出什么样的请求,我都希望我的回复能够回复.
控制器:
@RequestMapping(value = "/m/health", method = RequestMethod.GET, headers = "Accept=*")
public String runHealthCheck(HttpServletResponse response, HttpServletRequest request, Model model) throws Exception {
model = executeCheck(request, response, TEMPLATE, false, model);
model.addAttribute("accept", "text/plain");
response.setContentType("text/plain");
response.setCharacterEncoding("UTF-8");
return "m.health";
}
Run Code Online (Sandbox Code Playgroud)
JSP:
$ {}状态
我们正在筑巢几个实体.但是在检索时我们只想获得那些活跃的实体.
@Entity
public class System {
@Id
@Column(name = "ID")
private Integer id;
@OneToMany(mappedBy = "system")
private Set<Systemproperty> systempropertys;
}
@Entity
public class Systemproperty {
@Id
@Column(name = "ID")
private Integer id;
@Id
@Column(name = "ACTIVE")
private Integer active;
}
Run Code Online (Sandbox Code Playgroud)
在请求时Systemproperties
我只想获取属性active
(active = 1).
搜索我发现了一些hibernate注释和使用子查询的可能性.然而,两者都不适合我.即使我们目前正在使用hibernate,我也在考虑用Eclipselink替换它,因为我们目前不得不使用预先加载,我们可能会遇到性能问题.子查询不能很好地工作,因为我们正在嵌套几个级别.
Eclipselink似乎有一个可以工作的@Customizer注释,但它似乎遵循与hibernate @FilterDef
注释不同的概念,并且在切换时会产生额外的开销.
在@JoinColumn
似乎没有允许进一步的筛选.是否有标准的JPA方法来解决这个问题?
我想有一个很好的理由,但我不明白为什么有时我们会在同一台物理服务器上放置5个具有相同web应用程序的实例.
它与多处理器架构的优化有关吗?JVM或其他什么允许的最大ram限制?
春天新手.我遇到以下异常:
2012-06-14 16:20:57,719 [http-8080-6] ERROR com.nimchip.lmu.data.service.impl.CoworkerServiceImpl - Error sending mail:
org.springframework.mail.MailSendException: Mail server connection failed; nested exception is javax.mail.NoSuchProviderException: Unable to locate provider for protocol: smtp. Failed messages: javax.mail.NoSuchProviderException: Unable to locate provider for protocol: smtp
at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:400) ~[spring-context-support-3.1.0.RELEASE.jar:3.1.0.RELEASE]
at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:306) ~[spring-context-support-3.1.0.RELEASE.jar:3.1.0.RELEASE]
at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:296) ~[spring-context-support-3.1.0.RELEASE.jar:3.1.0.RELEASE]
at com.nimchip.lmu.data.service.impl.CoworkerServiceImpl.genUpdateNomination(CoworkerServiceImpl.java:224) ~[lmu-dataaccess-1.0.0.jar:na]
at com.nimchip.lmu.controller.coworkerNom.CoworkerController.genUpdateNomination(CoworkerController.java:312)
Run Code Online (Sandbox Code Playgroud)
我有一个mail-config.xml,它在我的web.xml中注册.这里是:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host" value="10.30.137.190"/>
<property name="port" value="25"/>
</bean>
</beans>
Run Code Online (Sandbox Code Playgroud)
我应该能够匿名登录到指定的邮件服务器,因此不需要用户或密码.
我错过了什么?
我正在通过jcc执行SQL查询来运行报告.当我打开程序的错误日志文件并检查SQL查询时,一切似乎都很好(没有额外或缺少括号,逗号等,语法很好)但是当我执行时我收到此错误:
[Report.execute()] DB2 SQL错误:SQLCODE = -104,SQLSTATE = 42601,SQLERRMC = ,; ATE IN(1,2,3,10,1);, DRIVER = 4.12.55
当我研究SQLCODE时,我发现它意味着查询中存在非法符号.我能找到什么来找到这个非法的符号?
这是查询
很抱歉这个小字体,但如果你缩放200%左右,你可以更好地看到查询.
非常感谢 :)
java ×7
jpa ×2
spring ×2
apache-tiles ×1
content-type ×1
db2 ×1
glassfish ×1
ios ×1
iphone ×1
jakarta-mail ×1
java-8 ×1
java-ee ×1
jboss ×1
jcc ×1
jpa-2.0 ×1
jpql ×1
junit ×1
one-to-many ×1
profile ×1
spring-mvc ×1
sql ×1
sqlcode ×1
tomcat ×1