Tag: spring boot

如何在java9中解析模块读取包错误

我试图通过spring-boot来理解java 9中的新模块化,所以我想运行一些简单的应用程序,例如: https : //github.com/tmatyashovsky/java9-springboot 我正在使用maven 3.5.0和java 9: Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-03T21:39:06+02:00) Maven home: ~/soft/apache-maven-3.5.0 Java version: 9-ea, vendor: Oracle Corporation Java home: /usr/lib/jvm/java-9-oracle Default locale: en_US, platform encoding: UTF-8 OS name: “linux”, version: “4.4.0-79-generic”, arch: “amd64”, family: “unix” 问题是我还有一些例外。 它是什么意思,我应该如何解决它? [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.1:compile (default-compile) on project api: Compilation failure: Compilation […]

spring-boot中的默认调度程序池大小是多少?

我正在使用spring-boot和@Scheduled注释来执行某些任务。 如何在spring-boot中找出默认的计划任务的默认池大小? 原因:以下类不并行执行作业,而是一个接一个地执行。 也许默认情况下只配置一个线程执行程序? @Service public class ZipFileTesterAsync { @Scheduled(fixedDelay = 60000, initialDelay = 500) public void run() throws Exception { System.out.println(“import 1”); TimeUnit.MINUTES.sleep(1); System.out.println(“import 1 finished”); } @Scheduled(fixedDelay = 60000, initialDelay = 1000) public void run2() throws Exception { System.out.println(“import 2”); TimeUnit.MINUTES.sleep(1); } } 结果:第一个完成后执行第二个作业。

如何在Spring Boot中禁用ErrorPageFilter?

我正在创建一个应该在Tomcat上运行的SOAP服务。 我正在为我的应用程序使用Spring Boot,类似于: @Configuration @EnableAutoConfiguration(exclude = ErrorMvcAutoConfiguration.class) public class AppConfig { } 我的网络服务(例子): @Component @WebService public class MyWebservice { @WebMethod @WebResult public String test() { throw new MyException(); } } @WebFault public class MyException extends Exception { } 问题: 每当我在webservice类中抛出exception时,服务器上都会记录以下消息: ErrorPageFilter:无法转发请求[/ services / MyWebservice]的错误页面,因为响应已经提交。 因此,响应可能具有错误的状态代码。 如果您的应用程序在WebSphere Application Server上运行,则可以通过将com.ibm.ws.webcontainer.invokeFlushAfterService设置为false来解决此问题 题: 我怎么能阻止这个?

无法处理配置类的导入候选项

我有一个Spring Boot项目,我可以在IntelliJ中成功运行,但是当我打包一个可执行jar时,我再也无法运行它了。 这是exception的堆栈跟踪: 18:13:55.254 [main] INFO oscaAnnotationConfigApplicationContext – Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@b3d7190: startup date [Wed Sep 07 18:13:55 CEST 2016]; root of context hierarchy 18:13:55.403 [main] WARN oscaAnnotationConfigApplicationContext – Exception encountered during context initialization – cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [el.dorado.App]; nested exception is java.lang.IllegalArgumentException: No auto configuration classes found […]

Spring引导外部配置属性文件

我有一个spring boot应用程序,我可以打包在一个我要部署到不同环境的战争中。 要自动执行此部署,可以更轻松地将配置文件外部化。 目前,src / main / resources中的application.properties文件一切正常。 然后我使用’mvn install’来构建可部署到tomcat的war。 但是我想使用一个不需要出现在mvn install上的.yml文件,但是在战争部署期间可以读取该文件,并且与我的战争相同或相同。 24.外部化配置显示spring boot将查找文件的位置和72.3更改应用程序外部属性的位置提供了有关如何配置此更多详细信息,但我只是不明白如何将其转换为我的代码。 我的应用程序类如下所示:package be.ugent.lca; Updated below 我需要在此文件中添加@PropertySource吗? 我如何参考某个相对路径? 我觉得它可能记录在那里作为大多数春季启动文档,但我只是不明白他们是如何做到这一点。 编辑 不确定这是否应该是一个单独的问题,但我认为它仍然是相关的。 设置os变量后,未找到yaml文件的错误消失了。 然而,当我没有应用程序.properties或.yml文件时,我仍然会再次遇到相同的错误。 应用现在看起来像这样: @Configuration **@PropertySource(“file:${application_home}/application.yml”)** @ComponentScan({“be.ugent.lca”,”be.ugent.sherpa.configuration”}) @EnableAutoConfiguration @EnableSpringDataWebSupport public class Application extends SpringBootServletInitializer{ public static void main(String[] args) { SpringApplication.run(Application.class, args); } application_home OS变量 $ echo $application_home C:\Masterproef\clones\la15-lca-web\rest-service\target 我的application.yml文件(它抱怨的部分): sherpa: package: base: […]

Tomcat不读取Spring-Boot应用程序属性

我是spring / java的新手,并且已经检查了spring-boot以查找我在工作的项目。 我一直在关注指南,最后有一个(半)工作的网络应用MVC + JPA用于数据访问。 当我通过Jar方法部署应用程序时,一切正常: java -jar build/libs/client.jar 但是,我们的应用程序最终将部署到Tomcat(v7.0.40),因此我需要从项目中创建war文件。 我在spring.io网站上跟随转换jar到战争指南并遇到了问题。 它似乎没有加载application.properties文件。 以下是重要的代码片段: 的src / main / JAVA /你好/ GreetingController: @Controller @Configuration public class GreetingController { @Value(“${app.username}”) private String username; @RequestMapping(“/greeting”) public String greeting(@RequestParam(value=”name”, required=false, defaultValue=”World”) String name, Model model) { model.addAttribute(“name”, name); model.addAttribute(“username”, username); return “greeting”; } } 的src / main / JAVA […]

Spring Boot 2.0迁移之后:driverClassName需要jdbcUrl

已解决:我的解决方案:我从DatabaseConfig.java中删除了dataSource()方法。 然后,应用程序成功启动:) 我刚刚将Spring Boot项目从1.5.x更新到2.0.0 。 在更新之前,此应用程序正常工作,但在更新后,我收到的一些错误如下。 有什么问题,你能帮帮我吗? 我在项目中使用PostgreSQL,Hibernate,JPA。 我也试过这个,但它对我不起作用。 谢谢你的时间 :) 这是问题: 2018-03-03 23:19:37.934 ERROR 42323 — [ main] com.zaxxer.hikari.HikariConfig : HikariPool-1 – dataSource or dataSourceClassName or jdbcUrl is required. 2018-03-03 23:19:37.938 WARN 42323 — [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization – cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘entityManagerFactory’ […]

Spring Boot App不会部署在Glassfish 4.1上

我有一个香草弹簧启动应用程序,由以下pom.xml组成 4.0.0 xxx.alexius myapp 1.0-SNAPSHOT war my app Core Application Platform org.springframework.boot spring-boot-starter-parent 1.2.2.RELEASE UTF-8 1.7 org.springframework.boot spring-boot-starter-data-jpa org.springframework.boot spring-boot-starter-data-mongodb org.springframework.boot spring-boot-starter-mobile org.springframework.boot spring-boot-starter-security org.springframework.boot spring-boot-starter-social-facebook org.springframework.boot spring-boot-starter-social-twitter org.springframework.boot spring-boot-starter-thymeleaf org.springframework.boot spring-boot-starter-web mysql mysql-connector-java runtime org.postgresql postgresql 9.4-1201-jdbc41 runtime org.springframework.boot spring-boot-starter-test test org.apache.maven.plugins maven-compiler-plugin 2.3.2 1.7 1.7 -Xlint:all true true 当我将它部署到Tomcat时,一切正常,但是当我尝试在Glassfish 4.1服务器上部署它时,我收到以下错误 SEVERE: Class [ […]

使用多个调度程序servlet / web上下文与spring boot

我创建了一个带有父上下文(服务)和子上下文(spring-webmvc控制器)的spring启动应用程序: @Configuration public class MainApiApplication { public static void main(String[] args) { new SpringApplicationBuilder() .parent(Services.class) .child(ApiOne.class, MainApiApplication.class) .run(args); } @Bean public EmbeddedServletContainerFactory servletContainer() { return new TomcatEmbeddedServletContainerFactory(); } } 现在我想为我的ApiTwo.class配置添加另一个客户端上下文(和DispatcherServlet)。 我想我必须做两件事: 将servletContainer(因此MainApiApplication.class配置)移出子上下文和 添加路径映射/ one / – > ApiOne.class和/ two / ApiTwo.class 什么是弹簧靴的方式呢?

Spring Boot CORSfilter – CORS预检频道没有成功

我需要在我的Spring Boot Web应用程序中添加CORSfilter。 我已经添加了CORS映射,如以下文档中所述http://docs.spring.io/spring/docs/current/spring-framework-reference/html/cors.html 这是我的配置: @Configuration @EnableWebMvc public class WebMvcConfig extends WebMvcConfigurerAdapter { @Override public void addCorsMappings(CorsRegistry registry) { // @formatter:off registry .addMapping(“/**”) .allowedOrigins(CrossOrigin.DEFAULT_ORIGINS) .allowedHeaders(CrossOrigin.DEFAULT_ALLOWED_HEADERS) .allowedMethods(“GET”, “POST”, “PUT”, “DELETE”, “OPTIONS”) .maxAge(3600L); // @formatter:on } … } 现在,当我尝试访问我的API时,我收到以下错误: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://example.com/api/v1.0/user. (Reason: CORS preflight channel […]