报错如下,请老师找一下问题
报错信息
java.lang.Exception: No tests found matching [{ExactMatcher:fDisplayName=demo1], {ExactMatcher:fDisplayName=demo1(com.imooc.aspectj.demo1.SpringDemo1)], {LeadingIdentifierMatcher:fClassName=com.imooc.aspectj.demo1.SpringDemo1,fLeadingIdentifier=demo1]] from org.junit.internal.requests.ClassRequest@5197848c at org.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:37) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createFilteredTest(JUnit4TestLoader.java:80) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:71) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:46) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:522) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)
2.ProductDao.java
package com.imooc.aspectj.demo1; public class ProductDao { public void save() { System.out.println("保存商品"); } public void update() { System.out.println("修改商品"); } public void delete() { System.out.println("删除商品"); } public void findOne() { System.out.println("查询一个商品"); } public void findAll() { System.out.println("查询所有商品"); } }
3.MyAspectAnno.java
package com.imooc.aspectj.demo1; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; /* * 切面类 */ @Aspect public class MyAspectAnno { @Before(value="execution(* com.imooc.aspectj.demo1.ProductDao.*(..))") public void before() { System.out.println("前置通知"); } }
4.SpringDemo1.java
package com.imooc.aspectj.demo1; import javax.annotation.Resource; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("classpath:applicationContext.xml") public class SpringDemo1 { @Resource(name="productDao") private ProductDao productDao; @Test public void demo1() { productDao.delete(); productDao.findAll(); productDao.findOne(); productDao.update(); productDao.save(); } }
5.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:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"> <!--开启AspectJ的注解开发,自动代理=====================--> <aop:aspectj-autoproxy/> <!--目标类===================--> <bean id="productDao" class="com.imooc.aspectj.demo1.ProductDao"/> <!--定义切面--> <bean class="com.imooc.aspectj.demo1.MyAspectAnno"/> </beans>
6.我的项目结构
1
收起
正在回答 回答被采纳积分+1
4回答
一叶知秋519
2018-09-17 18:54:42
同学的jar包依赖地址存在问题,将pom文件中的<dependencies>标签内的代码改为:
<dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>4.2.4.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>4.2.4.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-expression</artifactId> <version>4.2.4.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>4.2.4.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aop</artifactId> <version>4.2.4.RELEASE</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>4.2.4.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aspects</artifactId> <version>4.2.4.RELEASE</version> </dependency>
同学下载jar包的groupId是存在问题的。
建议同学修改以后再试下~
祝学习愉快!
慕数据4154996
2018-09-17 18:46:16
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.imooc</groupId> <artifactId>spring_aspectj</artifactId> <packaging>war</packaging> <version>0.0.1-SNAPSHOT</version> <name>spring_aspectj Maven Webapp</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> </dependency> <!-- 引入Spring的基本开发包 --> <dependency> <groupId>spring</groupId> <artifactId>spring-core</artifactId> <version>4.2.4.RELEASE</version> </dependency> <dependency> <groupId>spring</groupId> <artifactId>spring-context</artifactId> <version>4.2.4.RELEASE</version> </dependency> <dependency> <groupId>spring</groupId> <artifactId>spring-beans</artifactId> <version>4.2.4.RELEASE</version> </dependency> <dependency> <groupId>spring</groupId> <artifactId>spring-expression</artifactId> <version>4.2.4.RELEASE</version> </dependency> <dependency> <groupId>aopalliance</groupId> <artifactId>aopalliance</artifactId> <version>1.0</version> </dependency> <dependency> <groupId>spring</groupId> <artifactId>spring-aop</artifactId> <version>4.2.4.RELEASE</version> </dependency> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>1.8.9</version> </dependency> <dependency> <groupId>spring</groupId> <artifactId>spring-aspects</artifactId> <version>4.2.4.RELEASE</version> </dependency> <dependency> <groupId>spring</groupId> <artifactId>spring-test</artifactId> <version>4.2.4.RELEASE</version> </dependency> </dependencies> <build> <finalName>spring_aspectj</finalName> </build> </project>
慕数据4154996
2018-09-17 18:26:39
SSM主流框架入门与综合项目实战2018版
- 参与学习 人
- 提交作业 205 份
- 解答问题 4317 个
Java中非常实用的SSM整合开发内容,从Spring开始,到MyBaits的进阶内容,再到SpringMVC的应用,最后是SSM整合开发案例,逐步深入,助你成长为一名Java工程师!
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星