开发者

Is Tomcat 7.0.10 Java EE 6 Compliant? javax.inject woes

开发者 https://www.devze.com 2023-02-16 19:53 出处:网络
Folks- I\'m following an example from Craig Walls\' \"Spring in Action 3\" (MEAP edition) on Tomcat 7.0.10. Getting a compiler error in eclipse on the following import:

Folks- I'm following an example from Craig Walls' "Spring in Action 3" (MEAP edition) on Tomcat 7.0.10. Getting a compiler error in eclipse on the following import:

import javax.inject.In开发者_如何学Pythonject;

The error message is:

The import javax.inject cannot be resolved

I understand javax.inject is part of Java EE 6, is Tomcat 7 not Java EE 6 compliant? I have all the jars in $CATALINA/lib copied to my WEB-INF/lib directory, also did a manual search (jar -tvf) but couldn't find this package.

Any help will be greatly appreciated. Thanks.


Tomcat is a servlet container, therefore it has nothing to do with JSR-330 (javax.inject).

If you want to use JSR-330 annotations, you need to add JSR-330 jar to the classpath.


If you use Maven, you can use the following pom.xml and it will automatically download the Spring and Java EE jars for your project:

<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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.acmeco</groupId>
    <artifactId>SpringInjectDemo</artifactId>
    <version>1.0.0-SNAPSHOT</version>

    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>3.1.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>3.1.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>3.1.0.RELEASE</version>
        </dependency>       
        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</version>
        </dependency>
    </dependencies>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <repositories>
        <repository>
            <id>maven2-repository.dev.java.net</id>
            <name>Java.net Repository for Maven</name>
            <url>http://download.java.net/maven/2/</url>
            <layout>default</layout>
        </repository>
    </repositories>
</project>


Tomcat is just a Servlet container and is not Java EE 6 compliant. You can use GlassFish 3.1 (glassfish.org) which is a fully Java EE 6-compliant app server with clustering and high availability.

0

精彩评论

暂无评论...
验证码 换一张
取 消