Tag: spring boot

Maven Spring Boot插件:如何从另一个项目运行spring boot

https://docs.spring.io/spring-boot/docs/current/maven-plugin/usage.html 我有一个项目,有2个模块。 [Parent] |-pom.xml | [SpringBoot2App] | |-pom.xml | [test] | |-pom.xml (start goal here!) 我想在一个单独的项目中运行集成测试(maven failsafe插件),这是另一个模块。 在父模块的集成测试期间,是否可以配置spring boot maven插件来启动/停止子模块? 我尝试过这样的事情没有成功 org.springframework.boot spring-boot-maven-plugin com.SimpleServiceApplication ../SpringBoot2App/target/classes ../SpringBoot2App/target/test-classes start pre-integration-test 哪个不起作用。 我还尝试在读取插件超级类的源代码后添加“project”参数https://github.com/spring-projects/spring-boot/blob/master/spring-boot-project/spring-boot -tools /弹簧引导Maven的插件/ src目录/主/ JAVA /组织/ springframework的的/ boot /行家/ AbstractRunMojo.java com.SimpleServiceApplication ${project.parent.collectedProjects[0]} 这指的是正确的项目,如调试所示,但也不起作用。 请不要评论[0],我知道[0]不干净,是一个需要直接了解父pom模块排序的耦合。 我在org / springframework / boot / SpringApplication上得到一个java.lang.NoClassDefFoundError 我将starter-web项目添加到测试pom.xml,结果相同

Vaadin + Spring Boot错误:“无法增强@Configuration”和“定义了多个Servlet映射”

我是Spring和Vaadin的新手。 我正在尝试浏览视图导航教程 。 我想将来启用@Push来定期更新从DB获取的数据。 该项目非常非常简单。 我不使用配置类,也不使用任何XML – 仅Java注释。 任何人都可以帮我修复示例代码吗? 因为我收到了警告,我不知道可以用它做什么,忽略它们的结果是什么。 第一个是: onClassPostProcessor : Cannot enhance @Configuration bean definition ‘com.vaadin.spring.VaadinConfiguration’ since its singleton instance has been created too early. The typical cause is a non-static @Bean method with a BeanDefinitionRegistryPostProcessor return type: Consider declaring such methods as ‘static’. 另一个是只有当我添加compile(“com.vaadin:vaadin-push”)依赖时: oautil.IOUtils : More than one Servlet Mapping […]

Spring Boot Actuator – 无法禁用/ info端点

我尝试在application.yml配置文件中禁用生产环境的所有执行器端点: endpoints.enabled: false 它适用于除/ info之外的所有端点。 如何关闭给定环境的所有端点? 更新: 我正在做的项目也是Eureka的客户。 在状态页面和健康指标 ( http://cloud.spring.io/spring-cloud-netflix/spring-cloud-netflix.html )部分的Spring Cloud Netflix文档中,它说“Eureka实例默认为”/ info“和“/健康”分别“。 有没有解决方案来禁用这些端点? 我能够使用endpoints.enabled: false来禁用/ health端点,但不能使用/ info端点。

错误:尝试在空上下文对象上调用方法“format”

Spring-boot v1.4.1 Java v1.8 Thymeleaf v2.1.5。 我视图中的以下代码行: 我有基于SO问题SpringBoot Thymeleaf Ordinal Numbers的语法产生错误: org.springframework.expression.spel.SpelEvaluationException:EL1011E:(pos 11):方法调用:尝试在空上下文对象上调用方法格式(java.time.LocalDate,java.lang.String) 但是,如果我在没有Thymeleaf格式的情况下运行这行代码,它将工作并以默认格式呈现LocalDate对象表(“2016-05-25”)。 问题:为什么我收到’空上下文对象’错误,这是什么意思? 我如何编辑以获得我想要的格式?

使用spring-mybatis进行Spring-boot – 如何强制它记录所有SQL查询

我有一个简单的spring-boot-mybatis应用程序(请记住,请)。 Mybatis仅在发生故障时(在例外情况下)记录SQL查询。 请告诉我,如何强制它将所有SQL查询记录到控制台? 此刻我正在使用slf4j logger(由spring-boot自动配置)。 我找到了这个链接: http : //www.mybatis.org/mybatis-3/logging.html 但是我没有设法遵循它。 首先显示log4j配置,我不确定如果我正确理解:在application.properties配置是否足够? 提前致谢

Spring启动使用Thymeleaf作为模板发送电子邮件 – 配置不起作用

我在基于Spring Boot(最新的1.1.5.RELEASE)和Thymeleaf的WebApp上工作。 现在我想添加发送电子邮件的function,并使用Thymelaf作为模板引擎。 在pom.xml中我添加: org.springframework.integration spring-integration-mail javax.mail mail 1.4.7 javax.activation activation 1.1.1 遵循本教程: http : //www.thymeleaf.org/doc/articles/springmail.html 得到完整的(没有XML)Java配置: @Configuration public ThymeleafReplaceConfigurator { @Bean public JavaMailSender getJavaMailSenderImpl(){ JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl(); Properties props = new Properties(); /* some properties here */ javaMailSender.setJavaMailProperties(props); return javaMailSender; } @Bean public ClassLoaderTemplateResolver emailTemplateResolver(){ ClassLoaderTemplateResolver emailTemplateResolver = new ClassLoaderTemplateResolver(); emailTemplateResolver.setPrefix(“/mails/”); emailTemplateResolver.setSuffix(“.html”); […]

在Amazon Lambda上运行Spring Boot

我正在尝试在Amazon Lambda上部署Spring Boot应用程序。 我注意到如果快速连续调用处理程序 – spring尝试重新加载自己,重新设置datsources,重新加载bean等 无论如何,如果已经调用了main方法,那么告诉Spring Boot不要重新初始化自己吗? 谢谢Damien

带有Thymeleaf的SpringBoot – 未找到css

首先要说的是,我现在一直在寻找解决方案,现在我非常绝望。 在Spring Boot运行时,我无法从html页面访问css文件。 html.file AntiIntruder … Application.java @SpringBootApplication // adds @Configuration, @EnableAutoConfiguration, @ComponentScan @EnableWebMvc public class Application extends WebMvcConfigurerAdapter { public static void main(String[] args) { SpringApplication.run(Application.class, args); } @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler(“/assets/**”).addResourceLocations(“classpath:/assets/*”); } } 文件夹结构: 我已经尝试将css文件夹放入static文件夹和/或删除addResourcesHandlers,通过相对路径和其他一些东西引用css。 似乎没有解决这个问题。 请让我知道,如果你试图解决这个问题,但没有找到解决办法,那么我知道,我不会被忽视。

使用带有Spring Boot的Java API for WebSocket(JSR-356)

我是Spring的新手(并在stackoverflow上提问)。 我想通过Spring Boot启动嵌入式(Tomcat)服务器并向其注册JSR-356 WebSocket端点。 这是主要方法: @ComponentScan @EnableAutoConfiguration public class Server { public static void main(String[] args) { SpringApplication.run(Server.class, args); } } 这是配置的外观: @Configuration public class EndpointConfig { @Bean public EchoEndpoint echoEndpoint() { return new EchoEndpoint(); } @Bean public ServerEndpointExporter endpointExporter() { return new ServerEndpointExporter(); } } EchoEndpoint实现很简单: @ServerEndpoint(value = “/echo”, configurator = SpringConfigurator.class) public class […]

在抽象基类中使用@autowired

据我所知,不建议进行field injection 。 应该使用constructor 。 我在这里尝试做的是在基类的构造函数中使用@Autowired ,并使其可供所有子类访问。 在某些子类中,我还需要一些特定的bean来从它们的构造函数中@Autowired 。 演示代码如下: 基类: public abstract class Base { protected final MyDemoService myDemoService; @Autowired public Base(MyDemoService myDemoService) { this.myDemoService = myDemoService; } } inheritance(子)类: public class Sub extends Base { private final MySubService mySubService; @Autowired public Sub(MySubService mySubService) { this.mySubService = mySubService; } } 这将给我一个’无默认构造函数’错误。 它类似于问题: 类似的问题和答案 ,但它在这里不起作用。 […]