赞
踩
Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.0.0:exec (default-cli) on project spring_aop: Command execution failed.
的问题出现如下问题:
Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.0.0:exec (default-cli) on project
spring_aop: Command execution failed.
~之前是这样的:用的是main运行
public class MyTest {
public static void main(String[] args) {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
//动态代理代理的是接口
UserService userservice = (UserService) context.getBean("userservice");
userservice.add();
}
}
~改成了:用@Test
import com.niuyun.service.UserService; import com.niuyun.service.UserServiceImpl; import org.junit.Test; import org.springframework.context.support.ClassPathXmlApplicationContext; public class MyTest { @Test public void test(){ ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml"); //动态代理代理的是接口 UserService userservice = (UserService) context.getBean("userservice"); userservice.add(); } }
!扩展
@Test是JUnit测试的基础,他的作用:
1.指定将会抛出的异常类型
2.测试一断代码运行时间。
maven-compiler-plugin:用来编译Java文件,指定JDK版本等
exec-maven-plugin:用来执行class文件,其中插件配置中需指明执行类的路径。
<build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.6.0</version> <executions> <execution> <goals> <goal>java</goal> </goals> </execution> </executions> <configuration> <classpathScope>test</classpathScope> </configuration> </plugin> </plugins> </build>
~运行成功
方法一:
在setting->maven->Runner->VM Options
一栏中填入 -Dfile.encoding=gb2312
方法二:在pom.xml中添入(这个方法我试过,对于我没有解决乱码,可能对你们有用)
<properties>
<!-- 文件拷贝时的编码 -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<!-- 编译时的编码 -->
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
</properties>
方案二来自:参考博文
~希望可以帮助到您,解决问题
~~~感谢您的光临~~~
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。