我正在使用Git作为VCS的项目.我xyz从主人的主线分支切了一个分支.工作了一段时间后,我提交了我的代码并拉了分支主线.
拉得很好.然后我将代码与master合并.合并后,某些文件出现问题.合并后我没有提交代码.有人可以指导我如何中止这个合并并将我的分支机构带到我合并之前的状态吗?
我创建了一个名为BaseCron的bean,它有一个executeBefore()在spring的下面配置中配置的方法,用于拦截Crons类的所有方法调用并在它们之前执行.
该executeBefore()方法有一些验证.我之前验证了某些条件,如果它们是假的,我就是抛出异常.抛出异常会导致方法失败,因此Crons类中的方法不会执行.
它工作正常.
你可以建议一些其他的方法,我可以停止执行Crons类而不抛出异常.我试过回来但是没用.
<bean id="baseCronBean" class="com.myapp.cron.Jkl">
</bean>
<aop:config>
<aop:aspect id="cron" ref="baseCronBean">
<aop:pointcut id="runBefore" expression="execution(* com.myapp.cron.Abc.*.*(..)) " />
<aop:before pointcut-ref="runBefore" method="executeBefore" />
</aop:aspect>
</aop:config>
Run Code Online (Sandbox Code Playgroud)
Abc课程:
public class Abc {
public void checkCronExecution() {
log.info("Test Executed");
log.info("Test Executed");
}
}
Run Code Online (Sandbox Code Playgroud)
Jkl课程:
public class Jkl {
public void executeBefore() {
//certain validations
}
}
Run Code Online (Sandbox Code Playgroud) 当运行一个非常基本的Spring应用程序并使用FileSystemXmlApplicationContext创建Bean Factory时,我遇到NoSuchMethodError.
该beans.xml的文件是在与pom.xml的应用程序的根目录,如下所示:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
<bean id="person" class="com.xyz.practice.Person">
</bean>
</beans>
Run Code Online (Sandbox Code Playgroud)
Person类看起来像:
package com.xyz.practice;
public class Person {
public void speak(){
System.out.println("Hello I'm a Person");
}
}
Run Code Online (Sandbox Code Playgroud)
主类App.java如下所示:
package com.xyz.practice;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
public class App {
public static void main(String[] args) {
ApplicationContext context = new FileSystemXmlApplicationContext("beans.xml");
Person person = (Person) context.getBean("person");
person.speak();
}
}
Run Code Online (Sandbox Code Playgroud)
运行应用程序时,会引发以下异常:
INFO: Loading XML bean definitions from file [/home/salmank/Documents/springWithAbc/beans.xml]
Exception in thread "main" java.lang.NoSuchMethodError: org.springframework.beans.factory.config.ConfigurableListableBeanFactory.clearMetadataCache()V …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用SpringData Jpa在接口方法声明上使用@Query注释编写查询.
界面如下所示:
public interface MyService {
@Query("select * from employee e where e.projectId = ?1")
public List<Employee> getEmployeesWorkingOnAProject(String projectId) throws MyException;
}
Run Code Online (Sandbox Code Playgroud)
我还有一个实现此接口的类:
@Component
public class ProjectServiceImpl implements ProjectService {
}
Run Code Online (Sandbox Code Playgroud)
我不确定此查询执行将如何工作以及如何在imeplementing类中为getEmployeesWorkingOnAProject方法提供实现.
谢谢