Results 1 to 5 of 5

Thread: What Maven dependency to include for @Async

  1. #1

    Default What Maven dependency to include for @Async

    Hi all,

    I've just upgraded to Spring 3.0.2.RELEASE and want to use the @Async annotation. In Eclipse I get the error message "Async cannot be resolved to a type". Obviously the right jar is not in the classpath. Does anyone know which dependency to include in my POM? So far I have:

    Code:
    		<!-- SPRING -->
    		<dependency>
    			<groupId>org.springframework</groupId>
    			<artifactId>spring-aop</artifactId>
    			<version>3.0.2.RELEASE</version>
    		</dependency>
    		<dependency>
    			<groupId>org.springframework</groupId>
    			<artifactId>spring-aspects</artifactId>
    			<version>3.0.2.RELEASE</version>
    		</dependency>
    		<dependency>
    			<groupId>org.springframework</groupId>
    			<artifactId>spring-context</artifactId>
    			<version>3.0.2.RELEASE</version>
    		</dependency>
    		<dependency>
    			<groupId>org.springframework</groupId>
    			<artifactId>spring-core</artifactId>
    			<version>3.0.2.RELEASE</version>
    		</dependency>
    		<dependency>
    			<groupId>org.springframework</groupId>
    			<artifactId>spring-dao</artifactId>
    			<version>2.0.8</version>
    		</dependency>
    		<dependency>
    			<groupId>org.springframework</groupId>
    			<artifactId>spring-orm</artifactId>
    			<version>3.0.2.RELEASE</version>
    		</dependency>
    		<dependency>
    			<groupId>springmodules</groupId>
    			<artifactId>springmodules-validation</artifactId>
    			<version>0.4</version>
    		</dependency>
    		<dependency>
    			<groupId>org.springframework</groupId>
    			<artifactId>spring-webmvc</artifactId>
    			<version>3.0.2.RELEASE</version>
    		</dependency>
    Many thanks!
    Nes

  2. #2

    Default

    Hmm, not sure what I did, but after configuring Spring Security (unlikely) and many restarts/clean builds later (more likely) I can use @Async with the above dependencies.

    Thanks,
    Nes

  3. #3
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    @Async is in spring-context.

    I really hope that this isn't the pom you are going to use on a production build, because that will at some point give you issues. You are mixing spring versions (3.0.2 and 2.0.8) NEVER do this. You are also using an old spring modules versions, which might pull in another older version of spring.

    So I suggest check your classpath and jars that come with all the dependencies before you run into trouble!!!
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  4. #4

    Default

    Thanks Marten. Will review now.

    There was no newer (or 3.0.2) dependency for:

    Code:
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-dao</artifactId>
      <version>2.0.8</version>
    </dependency>
    I removed it and it didn't seem to harm my build so I guess the classes have been added to another package.

    Same for:

    Code:
    <dependency>
      <groupId>springmodules</groupId>
      <artifactId>springmodules-validation</artifactId>
      <version>0.4</version>
    </dependency>
    Which has a newer version (0.8a), but pulls in Spring 2.0.3 !

    I removed it and again I can still build so also the org.springframework.validation package must be included in another dependency.

    Thanks again for the warning.
    Nes

  5. #5
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    As I stated do proper dependency management. (mvn dependency:tree gives you a nice overview) and you might want to add some exclusions.

    Spring-dao is integrated in spring-tx, spring-jdbc, springmodules-validation has NOTHING to do with org.springframework.validation.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •