小编Rav*_*iga的帖子

Spring boot - 限制为7的备份日志文件数

在我们的spring-boot项目中,我们使用slf4j进行日志记录.以下是我们在application.properties文件中添加的配置

logging.file=/opt/logs/my_log.log
logging.level.org.springframework.web=INFO
logging.level.org.hibernate=INFO
logging.level.nl.yestelecom.boss=DEBUG
logging.level.com.github.isrsal.logging.LoggingFilter=DEBUG
Run Code Online (Sandbox Code Playgroud)

它只生成7个备份文件(my_log.log.1,my_log.log.2 ...,my_log.log.7),每个文件的大小为10.5MB,之后根本不会发生日志记录.

有没有办法改变这种行为?

我们查看了spring-boot的可用属性,但没有找到任何东西.任何建议表示赞赏.

java spring logback slf4j spring-boot

15
推荐指数
2
解决办法
2万
查看次数

使用scheduler-BeanCreationNotAllowedException进行Spring启动:创建名为'entityManagerFactory'的bean时出错:不允许创建Singleton bean

我们有一个带有调度程序的spring boot项目,它以固定的时间间隔从数据库中读取数据.

在使用maven从STS构建项目时,即使最终构建状态成功,我们在运行测试用例时也会在控制台中出现以下错误.

org.springframework.beans.factory.BeanCreationNotAllowedException:创建名为'entityManagerFactory'的bean时出错:当这个工厂的单例处于销毁状态时不允许使用单例bean创建(不要在destroy方法实现中从BeanFactory请求bean!)at Org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:216)位于org.springframework.beans.factory的org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299). org.springframework.beans.factory.BeanFactoryUtils.beansOfTypeIncludingAncestors(BeanFactoryUtils.java:)中org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:523)的support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) 276)at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.detectPersistenceExceptionTranslators(PersistenceExceptionTra)nslationInterceptor.java:162)org.springframework.data上的org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:145)org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) .gpa.repository.support.CrudMethodMetadataPostProcessor $ CrudMethodMetadataPopulatingMethodIntercceptor.invoke(CrudMethodMetadataPostProcessor.java:122)org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke (ExposeInvocationInterceptor.java:92)org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)位于com.sun的org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207).代理.$ Proxy70.findByTraIdAndTransactionNameAndExecutionTime(未知来源)at

申请文件

@SpringBootApplication
@PropertySource("classpath:application.properties")
@EnableScheduling
public class ProvisioningApplication {

    public static void main(String[] args) {

        SpringApplication.run(ProvisioningApplication.class, args);

    }
}
Run Code Online (Sandbox Code Playgroud)

调度程序文件

BusinessService具有读取数据库的逻辑

@Component
public class SchedulerJob {

    @Autowired
    BusinessService service;

    @Scheduled(fixedRate=300000) //5mnts
    public void schdeule() {
        service.startService();

    }
}
Run Code Online (Sandbox Code Playgroud)

测试文件

@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = ProvisioningApplication.class)
public class ProvisioningApplicationTests {

    @Test
    public void contextLoads() {
    }

}
Run Code Online (Sandbox Code Playgroud)

这里的问题是为什么spring boot在构建项目时运行调度程序任务以及它为什么抛出上述异常?

java hibernate exception scheduler spring-boot

5
推荐指数
1
解决办法
4838
查看次数

从springboot中排除maven依赖项

我有一个springboot项目,它将所有相关的jar添加到lib文件夹中.我怎么能避免这个?

我试过这个并没有用

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <!-- <excludeScope>compile</excludeScope>
                        <excludeArtifactIds>*</excludeArtifactIds>
                        <excludeGroupIds>*.*</excludeGroupIds> -->
        <exclude>
            <groupId>*.*</groupId>
            <artifactId>*</artifactId>
        </exclude>
    </configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)

我不想按提供的方式放置依赖项

还有其他方法吗?

java maven spring-boot

0
推荐指数
1
解决办法
1777
查看次数

标签 统计

java ×3

spring-boot ×3

exception ×1

hibernate ×1

logback ×1

maven ×1

scheduler ×1

slf4j ×1

spring ×1