在Java 8项目上工作,我从外部源复制文件.在其中一个源中,使用不可变位标志设置文件.
在OSX中,这是这样设置的
sudo chflags schg /path/to/file
Run Code Online (Sandbox Code Playgroud)
在Linux中
chattr +i /path/to/file
Run Code Online (Sandbox Code Playgroud)
我现在需要删除我复制的文件.我一直在使用Apache Commons IO来删除这样的目录,
FileUtils.deleteDirectory(new File("/path/here"));
Run Code Online (Sandbox Code Playgroud)
然而,这崩溃了java.io.IOException exception.
是否有任何跨平台方式删除这些文件?正在运行的进程是文件的所有者.
我想以编程方式在Spring Boot项目中注册Spring Converter.在过去的Spring项目中,我用这样的XML完成了它...
<!-- Custom converters to allow automatic binding from Http requests parameters to objects -->
<!-- All converters are annotated w/@Component -->
<bean id="conversionService"
class="org.springframework.context.support.ConversionServiceFactoryBean">
<property name="converters">
<list>
<ref bean="stringToAssessmentConverter" />
</list>
</property>
</bean>
Run Code Online (Sandbox Code Playgroud)
我试图找出如何在Spring Boot的SpringBootServletInitializer中做
更新:我通过传递StringToAssessmentConverter作为参数取得了一些进展getConversionService,但现在我收到了"No default constructor found"StringToAssessmentConverter类的错误.我不确定为什么Spring没有看到@Autowired构造函数.
@SpringBootApplication
public class Application extends SpringBootServletInitializer {
...
@Bean(name="conversionService")
public ConversionServiceFactoryBean getConversionService(StringToAssessmentConverter stringToAssessmentConverter) {
ConversionServiceFactoryBean bean = new ConversionServiceFactoryBean();
Set<Converter> converters = new HashSet<>();
converters.add(stringToAssessmentConverter);
bean.setConverters(converters);
return bean;
}
}
Run Code Online (Sandbox Code Playgroud)
这是转换器的代码......
@Component
public …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Maven 和 Intellij Idea 创建一个网络应用程序。安装在 .war 文件中时,测试工作正常。但是当我尝试用 jetty 引用我的休息时,我有很多错误情况:
在 ServletContext 资源 [/WEB-INF/rest-spring.xml] 中定义名称为“org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter#1”的 bean 创建时出错:bean 初始化失败;
嵌套异常是 java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/JsonProcessingException
以下是其余模块文件: Web.xml
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>restDispatcherServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!--the location of the spring context configuration file-->
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/rest-spring.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>restDispatcherServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
Run Code Online (Sandbox Code Playgroud)
休息弹簧.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/jdbc
http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<mvc:annotation-driven/>
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:model.properties</value>
<value>classpath:database.properties</value>
<value>classpath:automobile.properties</value>
</list>
</property> …Run Code Online (Sandbox Code Playgroud)