我使用MockMvc进行我的控制器测试
- @Test
- public void updateEvent() throws Exception{
- MockHttpServletRequestBuilder request = MockMvcRequestBuilders
- .post("/updateEvent");
- request.param("selectedEventStatusId","1");
- request.param("selectedEventTypeId","1");
- Event eventFromDb = createAndSaveEvent();
- request.param("idEvent",eventFromDb.getId().toString());
- request.param("name",eventFromDb.getName());
- request.param("description",eventFromDb.getDescription() +"____");//the reason of problem. if I will write request.param("description",eventFromDb.getDescription() ); its good work mapping if this field below
- request.param("date",new SimpleDateFormat("yyyy-MM-dd").format(eventFromDb.getDate()));
- request.param("eventDate",new SimpleDateFormat("yyyy-MM-dd").format(eventFromDb.getEventDate()));
- ResultActions result = mockMvc.perform(request).andDo(MockMvcResultHandlers.print());
- result.andExpect(MockMvcResultMatchers.view().name("redirect:eventDetails"));
- result.andExpect(MockMvcResultMatchers.model().attributeExists("idEvent"));
- result.andExpect(MockMvcResultMatchers.model().attributeExists("message"));
- }
描述字段标记为
- @Size(min=5)
- @Pattern(regexp="[a-zA-Z]*")
- private String description;
执行后我看到下一个stackTrace:
- org.springframework.web.util.NestedServletException: Handler processing Failed; nested exception is java.lang.NoClassDefFoundError: javax/el/PropertyNotFoundException
- at org.springframework.web.servlet.DispatcherServlet.triggerAfterCompletionWithError(DispatcherServlet.java:1259)
- at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:945)
- at ....
在生产模式下,它的工作不错,但在测试中我看到错误,如果我没有值的值
控制器方式:
- @RequestMapping(value = "/updateEvent",method = RequestMethod.POST)
- public String updateEvent(Model model,@Valid @modelattribute("existedEvent") Event event,BindingResult result,@modelattribute("linkedCandidates") Set<Candidate> candidates,@modelattribute("linkedvacancies") Set<Vacancy> vacancies,@RequestParam(required = true,value = "selectedEventStatusId")Integer EventStatusId,value = "selectedEventTypeId")Integer EventTypeId,RedirectAttributes attributes) {
- if (result.hasErrors()) {
- //model.addAttribute("idEvent",event.getId());
- event.setCandidates(candidates);
- event.setVacancies(vacancies);
- return "eventDetails";
- }
- eventService.updateEventAndLinkedEntities(event,candidates,vacancies,EventTypeId,EventStatusId);
- attributes.addAttribute("idEvent",event.getId() );
- attributes.addAttribute("message","submitted correctly at "+new Date());
- return "redirect:eventDetails";
- }
如果我更换
- request.param("description",eventFromDb.getDescription() +"____");
上
- request.param("description",eventFromDb.getDescription();//valid value here
这是好的作品
你可以帮忙解决吗?
UPDATE
pom.xml(子模块 – 这里运行的测试)
- <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.epam.hhs</groupId>
- <artifactId>ui</artifactId>
- <name>hhsystem ui</name>
- <packaging>war</packaging>
- <version>1.0.0-SNAPSHOT</version>
- <properties>
- <java-version>1.6</java-version>
- <org.springframework-version>3.2.3.RELEASE</org.springframework-version>
- <org.springsecurity-version>3.1.3.RELEASE</org.springsecurity-version>
- <org.aspectj-version>1.6.10</org.aspectj-version>
- <org.slf4j-version>1.6.6</org.slf4j-version>
- <!-- Spring -->
- <spring-framework.version>3.2.3.RELEASE</spring-framework.version>
- </properties>
- <dependencies>
- <!-- Spring -->
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context</artifactId>
- <version>${org.springframework-version}</version>
- <exclusions>
- <!-- Exclude Commons Logging in favor of SLF4j -->
- <exclusion>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-webmvc</artifactId>
- <version>${org.springframework-version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-beans</artifactId>
- <version>${org.springframework-version}</version>
- </dependency>
- <!-- Spring Security -->
- <dependency>
- <groupId>org.springframework.security</groupId>
- <artifactId>spring-security-web</artifactId>
- <version>${org.springsecurity-version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework.security</groupId>
- <artifactId>spring-security-config</artifactId>
- <version>${org.springsecurity-version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework.security</groupId>
- <artifactId>spring-security-core</artifactId>
- <version>${org.springsecurity-version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework.security</groupId>
- <artifactId>spring-security-taglibs</artifactId>
- <version>${org.springsecurity-version}</version>
- <exclusions>
- <exclusion>
- <artifactId>spring-aop</artifactId>
- <groupId>org.springframework</groupId>
- </exclusion>
- </exclusions>
- </dependency>
- <!-- Validation -->
- <dependency>
- <groupId>javax.validation</groupId>
- <artifactId>validation-api</artifactId>
- <version>1.1.0.Final</version>
- </dependency>
- <dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-validator</artifactId>
- <version>5.0.1.Final</version>
- </dependency>
- <!-- Core -->
- <dependency>
- <groupId>com.epam.hhs</groupId>
- <artifactId>core</artifactId>
- <version>1.0.9-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>com.epam.hhs</groupId>
- <artifactId>core</artifactId>
- <version>1.0.9-SNAPSHOT</version>
- <classifier>tests</classifier>
- </dependency>
- <!-- AspectJ -->
- <dependency>
- <groupId>org.aspectj</groupId>
- <artifactId>aspectjrt</artifactId>
- <version>${org.aspectj-version}</version>
- </dependency>
- <!-- Logging -->
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>${org.slf4j-version}</version>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>jcl-over-slf4j</artifactId>
- <version>${org.slf4j-version}</version>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <version>${org.slf4j-version}</version>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>1.2.15</version>
- <exclusions>
- <exclusion>
- <groupId>javax.mail</groupId>
- <artifactId>mail</artifactId>
- </exclusion>
- <exclusion>
- <groupId>javax.jms</groupId>
- <artifactId>jms</artifactId>
- </exclusion>
- <exclusion>
- <groupId>com.sun.jdmk</groupId>
- <artifactId>jmxtools</artifactId>
- </exclusion>
- <exclusion>
- <groupId>com.sun.jmx</groupId>
- <artifactId>jmxri</artifactId>
- </exclusion>
- </exclusions>
- <scope>runtime</scope>
- </dependency>
- <!-- @Inject -->
- <dependency>
- <groupId>javax.inject</groupId>
- <artifactId>javax.inject</artifactId>
- <version>1</version>
- </dependency>
- <!-- Servlet -->
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.5</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>javax.servlet.jsp</groupId>
- <artifactId>jsp-api</artifactId>
- <version>2.1</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>jstl</artifactId>
- <version>1.2</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>javax.el</groupId>
- <artifactId>el-api</artifactId>
- <version>2.2</version>
- <scope>provided</scope>
- </dependency>
- <!-- Test -->
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.7</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
- <version>1.9.5</version>
- </dependency>
- <!-- Mock MVC Test -->
- <!-- <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test-mvc</artifactId>
- <version>1.0.0.M2</version> <scope>test</scope> </dependency> -->
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-test</artifactId>
- <version>${spring-framework.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>hamcrest-all</artifactId>
- <version>1.3</version>
- <scope>test</scope>
- </dependency>
- <!-- <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId>
- <version>4.10</version> <scope>test</scope> <exclusions> <exclusion> <artifactId>hamcrest-core</artifactId>
- <groupId>org.hamcrest</groupId> </exclusion> </exclusions> </dependency> -->
- <!-- <dependency> <groupId>com.github.springtestdbunit</groupId> <artifactId>spring-test-dbunit</artifactId>
- <version>1.0.0</version> <scope>test</scope> </dependency> <dependency> <groupId>org.dbunit</groupId>
- <artifactId>dbunit</artifactId> <version>2.4.8</version> <scope>test</scope>
- </dependency> -->
- </dependencies>
- <repositories>
- <repository>
- <id>spring-milestone</id>
- <name>Spring Portfolio Milestone Repository</name>
- <url>http://repo.springsource.org/milestone/</url>
- </repository>
- </repositories>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-eclipse-plugin</artifactId>
- <version>2.9</version>
- <configuration>
- <additionalProjectnatures>
- <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
- </additionalProjectnatures>
- <additionalBuildcommands>
- <buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>
- </additionalBuildcommands>
- <downloadSources>true</downloadSources>
- <downloadJavadocs>true</downloadJavadocs>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.5.1</version>
- <configuration>
- <source>1.6</source>
- <target>1.6</target>
- <compilerArgument>-Xlint:all</compilerArgument>
- <showWarnings>true</showWarnings>
- <showDeprecation>true</showDeprecation>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <version>1.2.1</version>
- <configuration>
- <mainClass>org.test.int1.Main</mainClass>
- </configuration>
- </plugin>
- <!-- <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId>
- <version>2.12</version> <configuration> <forkMode>always</forkMode> </configuration>
- </plugin> -->
- </plugins>
- </build>
- </project>
pom.xml(父模块)
- <?xml version="1.0" encoding="UTF-8"?>
- <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.epam.hhs</groupId>
- <artifactId>core</artifactId>
- <version>1.0.9-SNAPSHOT</version>
- <name>hhsystem core</name>
- <!--<packaging>war</packaging> -->
- <properties>
- <!-- Generic properties -->
- <java.version>1.6</java.version>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
- <!-- Spring -->
- <spring-framework.version>3.2.3.RELEASE</spring-framework.version>
- <spring-data-jpa.version>1.3.2.RELEASE</spring-data-jpa.version>
- <org.springsecurity-version>3.1.3.RELEASE</org.springsecurity-version>
- <!-- Java EE / Java SE dependencies -->
- <jsp.version>2.2</jsp.version>
- <jstl.version>1.2</jstl.version>
- <servlet.version>2.5</servlet.version>
- <jaxb-impl.version>2.2.7</jaxb-impl.version>
- <!-- Hibernate / JPA -->
- <hibernate.version>4.2.1.Final</hibernate.version>
- <!-- Bean validation -->
- <hibernate-validator.version>4.3.1.Final</hibernate-validator.version>
- <!-- Database access -->
- <tomcat-jdbc.version>7.0.37</tomcat-jdbc.version>
- <ehcache.version>2.6.6</ehcache.version>
- <hsqldb.version>2.2.9</hsqldb.version>
- <!-- AOP -->
- <aspectj.version>1.7.2</aspectj.version>
- <!-- Logging -->
- <logback.version>1.0.13</logback.version>
- <slf4j.version>1.7.5</slf4j.version>
- <!-- RSS -->
- <rome.version>1.0</rome.version>
- <!-- Test -->
- <junit.version>4.11</junit.version>
- <hamcrest.version>1.3</hamcrest.version>
- <!-- Dates -->
- <jodatime-hibernate.version>1.3</jodatime-hibernate.version>
- <jodatime-jsptags.version>1.1.1</jodatime-jsptags.version>
- <jodatime.version>2.2</jodatime.version>
- <jadira-usertype-core.version>3.1.0.CR6</jadira-usertype-core.version>
- <!-- Web dependencies -->
- <webjars-bootstrap.version>2.3.0</webjars-bootstrap.version>
- <webjars-jquery-ui.version>1.9.2</webjars-jquery-ui.version>
- <webjars-jquery.version>1.9.0</webjars-jquery.version>
- <dandelion.datatables.version>0.8.14</dandelion.datatables.version>
- <MysqL.version>5.1.22</MysqL.version>
- </properties>
- <dependencies>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>1.2.17</version>
- </dependency>
- <dependency>
- <groupId>org.mule.transports</groupId>
- <artifactId>mule-transport-http</artifactId>
- <version>3.4.0</version>
- </dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>1.2.17</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-beans</artifactId>
- <version>3.2.1.RELEASE</version>
- </dependency>
- <!-- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>jstl</artifactId>
- <version>${jstl.version}</version>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>${servlet.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>javax.servlet.jsp</groupId>
- <artifactId>jsp-api</artifactId>
- <version>${jsp.version}</version>
- <scope>provided</scope>
- </dependency> -->
- <dependency>
- <groupId>com.sun.xml.bind</groupId>
- <artifactId>jaxb-impl</artifactId>
- <version>${jaxb-impl.version}</version>
- <scope>provided</scope>
- </dependency>
- <!-- SPRING,SPRING,SPRINGITY SPRING -->
- <dependency>
- <groupId>org.springframework.data</groupId>
- <artifactId>spring-data-jpa</artifactId>
- <version>${spring-data-jpa.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.springframework</groupId>
- <artifactId>*</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-jdbc</artifactId>
- <version>${spring-framework.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-aop</artifactId>
- <version>${spring-framework.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-webmvc</artifactId>
- <version>${spring-framework.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-tx</artifactId>
- <version>${spring-framework.version}</version>
- </dependency>
- <!-- used for EhCacheCacheManager -->
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context-support</artifactId>
- <version>${spring-framework.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-orm</artifactId>
- <version>${spring-framework.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-oxm</artifactId>
- <version>${spring-framework.version}</version>
- <exclusions>
- <exclusion>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-jms</artifactId>
- <version>${spring-framework.version}</version>
- </dependency>
- <!-- Database connection pool See here for more details on commons-dbcp
- versus tomcat-jdbc: http://blog.ippon.fr/2013/03/13/improving-the-performance-of-the-spring-petclinic-sample-application-part-3-of-5/ -->
- <dependency>
- <groupId>org.apache.tomcat</groupId>
- <artifactId>tomcat-jdbc</artifactId>
- <version>${tomcat-jdbc.version}</version>
- <scope>runtime</scope>
- </dependency>
- <!-- For MysqL only -->
- <!-- <dependency> <groupId>MysqL</groupId> <artifactId>MysqL-connector-java</artifactId>
- <version>${MysqL.version}</version> </dependency> -->
- <dependency>
- <groupId>com.microsoft.sqlserver</groupId>
- <artifactId>sqljdbc4</artifactId>
- <version>3.0</version>
- </dependency>
- <!-- <dependency> <groupId>MysqL</groupId> <artifactId>MysqL-connector-java</artifactId>
- <version>${MysqL.version}</version> </dependency> -->
- <!-- HIBERNATE -->
- <dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-core</artifactId>
- <version>${hibernate.version}</version>
- </dependency>
- <dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-entitymanager</artifactId>
- <version>${hibernate.version}</version>
- </dependency>
- <dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-validator</artifactId>
- <version>${hibernate-validator.version}</version>
- </dependency>
- <dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-ehcache</artifactId>
- <version>${hibernate.version}</version>
- </dependency>
- <dependency>
- <groupId>MysqL</groupId>
- <artifactId>MysqL-connector-java</artifactId>
- <version>5.1.25</version>
- </dependency>
- <!-- Webjars (static dependencies distributed as JAR files) -->
- <dependency>
- <groupId>org.webjars</groupId>
- <artifactId>bootstrap</artifactId>
- <version>${webjars-bootstrap.version}</version>
- </dependency>
- <dependency>
- <groupId>org.webjars</groupId>
- <artifactId>jquery-ui</artifactId>
- <version>${webjars-jquery-ui.version}</version>
- </dependency>
- <dependency>
- <groupId>org.webjars</groupId>
- <artifactId>jquery</artifactId>
- <version>${webjars-jquery.version}</version>
- </dependency>
- <!-- Test Artifacts -->
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-test</artifactId>
- <version>${spring-framework.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>${junit.version}</version>
- <scope>test</scope>
- </dependency>
- <!-- used by Spring MVC Test framework -->
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>hamcrest-library</artifactId>
- <version>${hamcrest.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.aspectj</groupId>
- <artifactId>aspectjrt</artifactId>
- <version>${aspectj.version}</version>
- </dependency>
- <dependency>
- <groupId>org.aspectj</groupId>
- <artifactId>aspectjweaver</artifactId>
- <version>${aspectj.version}</version>
- <scope>runtime</scope>
- </dependency>
- <!-- Spring Security -->
- <dependency>
- <groupId>org.springframework.security</groupId>
- <artifactId>spring-security-web</artifactId>
- <version>${org.springsecurity-version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework.security</groupId>
- <artifactId>spring-security-config</artifactId>
- <version>${org.springsecurity-version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework.security</groupId>
- <artifactId>spring-security-core</artifactId>
- <version>${org.springsecurity-version}</version>
- </dependency>
- <dependency>
- <groupId>org.ow2.easybeans</groupId>
- <artifactId>easybeans-uberjar-eclipselink</artifactId>
- <version>1.2.0-M1</version>
- </dependency>
- </dependencies>
- <!-- Maven plugin versions are mentioned in order to guarantee the build
- reproducibility in the long term -->
- <build>
- <defaultGoal>install</defaultGoal>
- <testResources>
- <testResource>
- <!-- declared explicitly so Spring config files can be placed next to
- their corresponding JUnit test class (see example with ValidatorTests) -->
- <directory>${project.basedir}/src/test/java</directory>
- </testResource>
- <testResource>
- <directory>${project.basedir}/src/test/resources</directory>
- </testResource>
- </testResources>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>3.0</version>
- <configuration>
- <compilerArguments>
- <Xlint />
- </compilerArguments>
- <verbose>true</verbose>
- <source>${java.version}</source>
- <target>${java.version}</target>
- <showWarnings>true</showWarnings>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-eclipse-plugin</artifactId>
- <version>2.9</version>
- <configuration>
- <downloadSources>true</downloadSources>
- <downloadJavadocs>true</downloadJavadocs>
- <wtpversion>2.0</wtpversion>
- <sourceIncludes>
- <sourceInclude>**/*.*</sourceInclude>
- </sourceIncludes>
- <additionalBuildcommands>
- <buildCommand>
- <name>org.springframework.ide.eclipse.core.springbuilder</name>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.m2e.core.maven2Builder</name>
- </buildCommand>
- </additionalBuildcommands>
- <additionalProjectnatures>
- <projectnature>org.eclipse.jdt.core.javanature</projectnature>
- <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
- <projectnature>org.eclipse.m2e.core.maven2Nature</projectnature>
- </additionalProjectnatures>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-assembly-plugin</artifactId>
- <version>2.4</version>
- <configuration>
- <descriptorRefs>
- <descriptorRef>jar-with-dependencies</descriptorRef>
- </descriptorRefs>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.tomcat.maven</groupId>
- <artifactId>tomcat7-maven-plugin</artifactId>
- <version>2.0</version>
- <configuration>
- <server>tomcat-development-server</server>
- <port>9966</port>
- <path>/petclinic</path>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <version>2.4</version>
- <executions>
- <execution>
- <goals>
- <goal>test-jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </project>
我重新启动我的电脑,现在我看到其他错误(也许我改变的东西但我发布了实际的dtate的pom.xml)
- org.springframework.web.util.NestedServletException: Handler processing Failed; nested exception is java.lang.NoSuchMethodError: javax.el.ExpressionFactory.newInstance()Ljavax/el/ExpressionFactory;
- at org.springframework.web.servlet.DispatcherServlet.triggerAfterCompletionWithError(DispatcherServlet.java:1259)
- at ...
如果我在2.2上更改jsp-api版本
我看到下一个痕迹:
@H_301_50@
- updateEvent(com.epam.hhsystem.web.controllers.EventMenuControllerTest) Time elapsed: 0.398 sec <<< ERROR!
- org.springframework.web.util.NestedServletException: Handler processing Failed; nested exception is java.lang.ExceptionInInitializerError
- at org.springframework.web.servlet.DispatcherServlet.triggerAfterCompletionWithError(DispatcherServlet.java:1259)
- at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:945)
- at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
- ....
- Caused by: java.lang.ExceptionInInitializerError
- at org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator.interpolateExpression(ResourceBundleMessageInterpolator.java:227)
- ....
- Caused by: javax.el.ELException: Provider com.sun.el.ExpressionFactoryImpl not found
- at javax.el.FactoryFinder.newInstance(FactoryFinder.java:97)
- ...
- Caused by: java.lang.ClassNotFoundException: com.sun.el.ExpressionFactoryImpl
- at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
解决方法
我遇到同样的问题,添加以下依赖关系解决了这个问题.
当遇到javax / el / PropertyNotFoundException时,这意味着你错过了el-api依赖,可以添加以下jar
- <dependency>
- <groupId>javax.el</groupId>
- <artifactId>el-api</artifactId>
- <version>2.2</version>
- <scope>provided</scope>
- </dependency>
要么
- <dependency>
- <groupId>javax.el</groupId>
- <artifactId>javax.el-api</artifactId>
- <version>3.0.0</version>
- <scope>test</scope>
- </dependency>
那么你遇到了ClassNotFoundException:com.sun.el.ExpressionFactoryImpl,你错过了el-impl jar:
@H_301_50@ @H_301_50@
- <dependency>
- <groupId>org.glassfish.web</groupId>
- <artifactId>el-impl</artifactId>
- <version>2.2</version>
- <scope>test</scope>
- </dependency>