1

I'm using Maven3 in Linux (CentOs 5.x)

And run linux) mvn install -Preal

But following error occurs.


Here's error messages

...
[ERROR] /data/byto_openapi/src/main/java/com/byto/openapi/home/HomeServiceImpl.java:[36,51] package org.springframework.beans.factory.annotation does not exist
[ERROR] /data/byto_openapi/src/main/java/com/byto/openapi/home/HomeServiceImpl.java:[37,51] package org.springframework.beans.factory.annotation does not exist
[ERROR] /data/byto_openapi/src/main/java/com/byto/openapi/home/HomeServiceImpl.java:[38,37] package org.springframework.orm.ibatis does not exist
[ERROR] /data/byto_openapi/src/main/java/com/byto/openapi/home/HomeServiceImpl.java:[39,48] package org.springframework.security.core.context does not exist
[ERROR] /data/byto_openapi/src/main/java/com/byto/openapi/home/HomeServiceImpl.java:[40,52] package org.springframework.security.core.userdetails does not exist
[ERROR] /data/byto_openapi/src/main/java/com/byto/openapi/home/HomeServiceImpl.java:[41,37] package org.springframework.stereotype does not exist
[ERROR] /data/byto_openapi/src/main/java/com/byto/openapi/home/HomeServiceImpl.java:[42,49] package org.springframework.transaction.annotation does not exist
[ERROR] /data/byto_openapi/src/main/java/com/byto/openapi/home/HomeServiceImpl.java:[43,40] package org.springframework.web.multipart does not exist
[ERROR] /data/byto_openapi/src/main/java/com/byto/openapi/home/HomeServiceImpl.java:[44,40] package org.springframework.web.multipart does not exist
[ERROR] /data/byto_openapi/src/main/java/com/byto/openapi/home/HomeServiceImpl.java:[56,24] package com.sun.mail.smtp does not exist
[ERROR] /data/byto_openapi/src/main/java/com/byto/openapi/home/HomeServiceImpl.java:[58,1] cannot find symbol
[ERROR] symbol: class Service
[ERROR] @Service
[ERROR] /data/byto_openapi/src/main/java/com/byto/openapi/home/HomeServiceImpl.java:[59,1] cannot find symbol
[ERROR] symbol: class Transactional
[ERROR] @Transactional
[ERROR] /data/byto_openapi/src/main/java/com/byto/openapi/home/HomeServiceImpl.java:[64,9] cannot find symbol
...

And this is CLASSPATH

declare -x CLASSPATH=".:/usr/java/jdk/lib/tools.jar:/usr/local/tomcat/lib:/usr/local/tomcat/lib/servlet-api.jar:/usr/local/tomcat/lib/mysql-connector-java-5.1.17-bin.jar:/usr/local/tomcat/webapps/ROOT/WEB-INF/classes:/usr/local/tomcat/webapps/ROOT/WEB-INF/lib/bcprov-jdk16-146.jar:/usr/local/tomcat/webapps/ROOT/WEB-INF/lib/bcprov-ext-jdk16-146.jar:/usr/local/tomcat/webapps/ROOT/WEB-INF/lib/commons-lang-2.6.jar:/usr/local/tomcat/webapps/ROOT/WEB-INF/lib/javapns-jdk16-161.jar:/usr/local/tomcat/webapps/ROOT/WEB-INF/lib/log4j-1.2.16.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib:/data/byto_openapi/src/main/webapp/WEB-INF/lib/aspectjweaver-1.6.8.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/jstl-1.2.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/cglib-2.2.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/tiles-template-2.2.2.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/commons-digester-2.0.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/bcprov-ext-jdk16-146.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/commons-fileupload-1.2.2.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/log4j-1.2.14.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/commons-lang-2.1.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/spring-security-config-3.0.5.RELEASE.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/ibatis-sqlmap-2.3.4.726.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/spring-orm-3.0.5.RELEASE.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/spring-security-ldap-3.0.5.RELEASE.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/commons-lang-2.6.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/commons-pool-1.3.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/commons-beanutils-1.8.0.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/spring-security-core-3.0.5.RELEASE.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/commons-dbcp-1.2.2.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/tiles-api-2.2.2.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/spring-tx-3.0.5.RELEASE.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/mail.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/aspectjrt-1.6.9.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/spring-test-3.0.5.RELEASE.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/slf4j-log4j12-1.5.2.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/derbyclient-10.4.2.0.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/spring-asm-3.0.5.RELEASE.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/spring-context-3.0.5.RELEASE.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/spring-jdbc-3.0.5.RELEASE.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/spring-security-acl-3.0.5.RELEASE.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/javapns-jdk16-161.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/spring-webmvc-3.0.5.RELEASE.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/asm-3.1.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/slf4j-api-1.5.2.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/aopalliance-1.0.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/jcl-over-slf4j-1.5.10.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/spring-security-web-3.0.5.RELEASE.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/spring-context-support-3.0.5.RELEASE.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/spring-core-3.0.5.RELEASE.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/commons-io-1.3.2.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/activation.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/jackson-mapper-asl-1.9.2.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/tiles-servlet-2.2.2.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/spring-aop-3.0.5.RELEASE.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/mysql-connector-java-5.1.19-bin.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/spring-ldap-core-1.3.0.RELEASE.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/spring-expression-3.0.5.RELEASE.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/spring-beans-3.0.5.RELEASE.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/cos.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/tiles-jsp-2.2.2.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/org.springframework.roo.annotations-1.0.2.RELEASE.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/tiles-core-2.2.2.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/jackson-core-asl-1.9.2.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/junit-4.7.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/spring-security-taglibs-3.0.5.RELEASE.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/spring-web-3.0.5.RELEASE.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/bcprov-jdk16-146.jar:/data/byto_openapi/src/main/webapp/WEB-INF/lib/javax.inject-1.jar"

As you can see all the JARs are included in CLASSPATH..


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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>cyoz</groupId>
<artifactId>cyoz</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>

<properties>
    <database.defaultAutoCommit>true</database.defaultAutoCommit>
    <database.validationQuery>select 1</database.validationQuery>
    <database.testWhileIdle>true</database.testWhileIdle>
    <database.timeBetweenEvictionRunsMillis>7200000</database.timeBetweenEvictionRunsMillis>

    <spring.version>3.0.5.RELEASE</spring.version>
    <tiles.version>2.2.2</tiles.version>
    <image.path>/data/api_svn_www/file/image</image.path>
</properties>

<build>
    <sourceDirectory>${basedir}/src/main/java</sourceDirectory>
    <scriptSourceDirectory>${basedir}/src/main/scripts</scriptSourceDirectory>
    <testSourceDirectory>${basedir}/src/test/java</testSourceDirectory>
    <outputDirectory>${basedir}/target/classes</outputDirectory>
    <testOutputDirectory>${basedir}/target/test-classes</testOutputDirectory>

    <resources>
        <resource>
            <directory>${basedir}/src/main/webapp</directory>
            <targetPath>${basedir}/target/webapp</targetPath>
        </resource>
        <resource>
            <directory>${basedir}/src/main/resources</directory>
            <targetPath>${basedir}/target/classes</targetPath>
            <filtering>true</filtering>
        </resource>
    </resources>

    <testResources>
        <testResource>
            <directory>${basedir}/src/test/resources</directory>
        </testResource>
    </testResources>

    <filters>
        <filter>${basedir}/src/main/resources/spring-common-bean-context.xml</filter>
        <filter>${basedir}/src/main/resources/byto.cyoz.properties</filter>
    </filters>

</build>

<profiles>
    <profile>
        <id>dev</id>
        <properties>
            <database.classname>me.kun.log4jdbc.DriverSpy</database.classname>
            <database1.url>jdbc:log4jdbc:mysql://211.174.62.34:3306/bytoapi?autoReconnect=true</database1.url>
            <database1.username>bytoapi</database1.username>
            <database1.password>bytoapi1213</database1.password>
            <database2.url>jdbc:log4jdbc:mysql://211.174.62.34:3306/byto_memo?autoReconnect=true</database2.url>
            <database2.username>byto_memo</database2.username>
            <database2.password>memo1213</database2.password>
        </properties> 
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation> 

        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>2.1.1</version>
                    <configuration>
                        <warSourceDirectory>src/main/webapp/</warSourceDirectory>
                        <webXml>src/main/webapp/WEB-INF/web.xml</webXml>
                    </configuration>
                </plugin>
                <plugin>
                    <artifactId>maven-eclipse-plugin</artifactId>
                    <version>2.7</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>
                        <wtpversion>1.5</wtpversion>
                    </configuration>
                </plugin>
                <plugin>
                    <artifactId>maven-idea-plugin</artifactId>
                    <version>2.2</version>
                    <configuration>
                        <downloadSources>true</downloadSources>
                        <downloadJavadocs>true</downloadJavadocs>
                        <dependenciesAsLibraries>true</dependenciesAsLibraries>
                        <useFullNames>false</useFullNames>
                    </configuration>
                </plugin>
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>1.5</source>
                        <target>1.5</target>
                        <!--<encoding>EUC-KR</encoding> -->
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.zeroturnaround</groupId>
                    <artifactId>jrebel-maven-plugin</artifactId>
                    <version>1.1.1</version>
                    <executions>
                        <execution>
                            <id>generate-rebel-xml</id>
                            <phase>process-resources</phase>
                            <goals>
                                <goal>generate</goal>
                            </goals>
                            <inherited>false</inherited>
                            <configuration>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>tomcat-maven-plugin</artifactId>
                    <version>1.1</version>
                    <configuration>
                        <url>http://211.174.62.34:8080/manager/html</url>
                        <path>/cyoz</path>
                        <username>tomcat</username>
                        <password>tomcat</password>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>

    <profile>
        <id>real</id>
        <properties>
            <database.classname>com.mysql.jdbc.Driver</database.classname>
            <database1.url>jdbc:mysql://127.0.0.1:3306/bytoapi?autoReconnect=true</database1.url>
            <database1.username>bytoapi</database1.username>
            <database1.password>bytoapi1213</database1.password>
            <database2.url>jdbc:mysql://127.0.0.1:3306/byto_memo?autoReconnect=true</database2.url>
            <database2.username>byto_memo</database2.username>
            <database2.password>memo1213</database2.password>
        </properties>
    </profile>

</profiles>

<dependencies>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.5.2</version>
    </dependency>

    <dependency>
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-mapper-asl</artifactId>
        <version>1.9.2</version>
    </dependency>
</dependencies>


linux /etc/profile which set CLASSPATH to compile *.java

# tomcat CLASSPATH
SOURCE_FOLDER=/data/byto_openapi
LIBRARY_FOLDER=$SOURCE_FOLDER/src/main/webapp/WEB-INF/lib
export CLASSPATH=$CLASSPATH:$LIBRARY_FOLDER
for file in `find $LIBRARY_FOLDER -name "*.jar" -type f`
do
    export CLASSPATH=$CLASSPATH:$file
done
4

1 に答える 1

3

CLASSPATHMavenは、依存関係を取得するために変数を検索しません。代わりに、ファイルで指定されているように独自の依存関係を管理しpom.xmlます。確かに、これが私の本でMavenを使用する最大の理由です。

Mavenをご覧ください-Mavenを使用した依存関係管理のクイックスタートについては、依存関係メカニズムの概要をご覧ください。

Mavenプラグインで使用される実際のクラスパスを検査するには、--debugたとえば、引数を使用してビルドを実行します

mvn --debug clean install -Preal

于 2012-07-18T06:56:00.130 に答える