2 raspberrymonster RaspberryMonster 于 2016.09.21 18:03 提问

maven 打包工程到 jar 包 却不包含自己写的代码 怎么回事

打包部分的配置

 <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>2.1.2</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <appendAssemblyId>false</appendAssemblyId>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    <archive>
                        <manifest>
                            <mainClass>com.cyan.Action</mainClass>
                        </manifest>
                    </archive>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>assembly</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

打出来的jar包含依赖包的所有class文件、META-INF也有,却没有我自己写的代码,为什么

2个回答

lanjian056
lanjian056   2016.09.30 14:46
已采纳
  build标签中增加一下这个配置:
        <sourceDirectory>src/main/java</sourceDirectory>
    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
        </resource>
    </resources>

lanjian056
lanjian056   2016.09.30 14:48

build标签中增加一下这个配置:
src/main/java


src/main/resources
true

Csdn user default icon
上传中...
上传图片
插入图片