我正在使用m2eclipse在Eclipse中编译一个项目.我在Eclipse中设置JDK路径,如下所示:
Windows-->preferences-->installed jres--> jdk1.7.xx path
Run Code Online (Sandbox Code Playgroud)
但这显示出错误
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.424s
[INFO] Finished at: Tue Oct 29 15:21:01 IST 2013
[INFO] Final Memory: 5M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler- plugin:3.1:compile (default-compile) on project TEST-WEB: Compilation failure
[ERROR] No compiler is provided …
Run Code Online (Sandbox Code Playgroud) 如果在项目类路径中不存在,我们如何通过jvm参数加载logback.xml?
我正在使用
-Dlogback.configuration=file:C:\logbacs\logback.xml
Run Code Online (Sandbox Code Playgroud)
但这不起作用.
我想JPA
和Postgres 进行批量upsert .我不能使用merge,因为我正在检查不是PK的Unique Constraint上的冲突.我发现要在postgres中进行upsert,我们现在可以使用ON Conflict功能.所以基本上我想在中执行本机查询JPA
.查询将如下:
INSERT INTO user (user_id, display_name )
VALUES('1', 'sg27')
ON CONFLICT (user_id) DO UPDATE
SET display_name = 'sg27' RETURNING *;
Run Code Online (Sandbox Code Playgroud)
我将循环遍历对象列表并进行查询.
所以我的问题是在本机查询插入的情况下,我们可以使用手动刷新em.flush()
.它是否适用于批量插入.
如果没有,那么有人可以告诉我这个问题的可能解决方案是什么?
谢谢你的时间.
我正在探索Guice功能并面临一种奇怪的行为 - 当我声明变量为
@Inject
@Named("dragon")
Dragon dragon2;
Run Code Online (Sandbox Code Playgroud)
注入按预期工作,但是当我想将dragon2声明为接口(它实现了Creature)时,即
@Inject
@Named("dragon")
Creature dragon2;
Run Code Online (Sandbox Code Playgroud)
我收到一个错误
没有实现warlock.rincewind.creatures.Creature注释与@com.google.inject.name.Named(value=dragon)
绑定.
这是我的提供者方法:
@Named("dragon")
@Provides
public Dragon providesDragon() {
Dragon d = new Dragon("Morkeleb");
return d;
}
Run Code Online (Sandbox Code Playgroud)
我知道,有很多不同的方法可以克服这个问题(最简单的方法是将更改类型提供给Creature),但我试图找到这种限制的原因.
我需要添加 HTTP \xe2\x80\x9cFeature-Policy\xe2\x80\x9d 响应标头,但我没有找到任何方法在 spring 中实现此标头,例如 -
\n\n@EnableWebSecurity\npublic class WebSecurityConfig extends WebSecurityConfigurerAdapter {\n\n @Override\n protected void configure(HttpSecurity http) throws Exception {\n http\n // ...\n .headers()\n .contentSecurityPolicy("script-src \'self\' https://trustedscripts.example.com; object-src https://trustedplugins.example.com; report-uri /csp-report-endpoint/");\n }\n
Run Code Online (Sandbox Code Playgroud)\n\n我可以在这里看到规范草案,但没有太多关于在 Spring 中使用它的信息。任何建议将不胜感激。
\n在调用控制器中的方法之前,是否有任何类似于@PreAuthorize
或@PreFilter
我可以用来运行代码的注释?
我需要将信息添加到请求上下文(特定于被调用的方法),然后由 ExceptionHandler
.
例如
@RestController
public MyController{
@UnkwonwAnnotation("prepareContext(request.getAgentId())"){
public ResponseEntity method1(RequestA requestA) {
...
}
@UnkwonwAnnotation("prepareContext(request.getUserName())"){
public ResponseEntity method1(RequestB requestB) {
...
}
}
Run Code Online (Sandbox Code Playgroud)
我实际上可以使用@PreAuthorize
但感觉不对
在我的项目中,我想为动态Web应用程序创建一个耳朵,并将依赖类型定义为web部件的战争和jar部分的类似
<dependencies>
<dependency>
<groupId>test.vias</groupId>
<artifactId>test-web</artifactId>
<version>1.0.0-SNAPSHOT</version>
<type>war</type>
</dependency>
<dependency>
<groupId>test.vias</groupId>
<artifactId>test-service</artifactId>
<version>1.0.0-SNAPSHOT</version>
<type>jar</type>
</dependency>
Run Code Online (Sandbox Code Playgroud)
现在问题是,我们可以在pom.xml中为依赖项目模块定义多少类型的依赖.
我正在尝试创建一个示例应用程序,Spring hateos
并且遇到以下异常:
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/hetos-medias]]
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:192)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1123)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:816)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/hetos-medias]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
... 6 more
Caused by: java.lang.NoSuchMethodError: org.apache.tomcat.util.res.StringManager.getManager(Ljava/lang/Class;)Lorg/apache/tomcat/util/res/StringManager;
at org.apache.tomcat.websocket.WsWebSocketContainer.<clinit>(WsWebSocketContainer.java:77)
at org.apache.tomcat.websocket.server.WsSci.init(WsSci.java:131)
at org.apache.tomcat.websocket.server.WsSci.onStartup(WsSci.java:47)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5481)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 6 more
Run Code Online (Sandbox Code Playgroud)
看起来可能有重复的jar用于类,org.apache.tomcat.util.res.StringManager.getManager
但我在类路径中找不到任何重复的jar。我正在使用tomcat 7,以下是我pom.xml
和图书馆的详细信息。
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-hateoas</artifactId>
<version>1.4.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<version>1.4.0.RELEASE</version> …
Run Code Online (Sandbox Code Playgroud) 我logback.xml
喜欢这个:
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="2 seconds">
<include resource="org/springframework/boot/logging/logback/base.xml"/>
<jmxConfigurator/>
<logger name="org.springframework" level="INFO"/>
<logger name="org.springframework.web.filter.CommonsRequestLoggingFilter" level="DEBUG"/>
<logger name="com.mypackage" level="WARN"/>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>
%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</pattern>
</encoder>
</appender>
<turboFilter class="ch.qos.logback.classic.turbo.DynamicThresholdFilter">
<Key>dynamicLogLevel</Key>
<DefaultThreshold>DEBUG</DefaultThreshold>
<MDCValueLevelPair>
<value>dynamicLogLevelDEBUG</value>
<level>DEBUG</level>
</MDCValueLevelPair>
<!-- dynamicLogLevelERROR for testing -->
<MDCValueLevelPair>
<value>dynamicLogLevelERROR</value>
<level>ERROR</level>
</MDCValueLevelPair>
</turboFilter>
.....
</configuration>
Run Code Online (Sandbox Code Playgroud)
我想设置的记录水平,追加程序,滚动现行政策logback.xml
中application.yaml
.
我已经浏览了这个Doc,但没有找到足够的信息.
我正在使用spring-boot 1.4.4-RELEASE
.
它有点用于寻找新页面的问题.我pdfContentByte
使用下面的代码将第一页之后的数据放到下一页但不幸的iText
是没有生成新的页面.
//step1
itextDocument = new com.itextpdf.text.Document(PageSize.A4, 50, 50, 30, 65);
writer = PdfWriter.getInstance(itextDocument, new FileOutputStream(RESULT));
itextDocument.open();
writer.setPageEmpty(true);
itextDocument.newPage();
// step 2 == design and set the postions
// Measuring a String in Helvetica
Font font = new Font(FontFamily.TIMES_ROMAN, 10);
BaseFont romanFont = font.getCalculatedBaseFont(false);
// Drawing lines to see where the text is added
PdfContentByte canvas = writer.getDirectContent();
canvas.saveState();
canvas.stroke();
canvas.restoreState();
// Adding text with PdfContentByte.showTextAligned()
canvas.beginText();
canvas.setFontAndSize(romanFont, 10);
//=================== get data from xml and put in …
Run Code Online (Sandbox Code Playgroud) java ×7
maven ×3
spring ×3
logback ×2
logging ×2
spring-boot ×2
batch-insert ×1
eclipse ×1
guice ×1
hibernate ×1
itext ×1
itextsharp ×1
java-7 ×1
jpa ×1
m2eclipse ×1
postgresql ×1
tomcat ×1
upsert ×1
web ×1
yaml ×1