Ant升级转Maven全面总结

将旧项目从Ant迁移到Maven的4个简单步骤 一段时间以来,我们一直在考虑将构建从蚂蚁移植到Maven。 它发生在上个月,实际上比我们预期的要简单。 根据我的经验,这里简要介绍了我们遵循的步骤。 我们的应用程序是一个具有多个框架和技术的企业Web应用程序构建,并作为单个WAR部署。 1.创建Maven项目目录结构 如Maven用户指南中所述,创建以下目录结构。 我们已经在项目的新文件夹下完成了此操作。 2.移动文件/文件夹并保... 阅读详情
AI摘要

本文详细介绍了从Ant项目升级到Maven的过程,包括项目结构转换、配置Maven插件、解决常见错误等内容,有助于理解Maven工作原理并顺利完成项目迁移。

1. 描述

最近一直在忙于Ant项目升级Maven的工作,在升级的过程中遇到了很多的错误。一路坎坎坷坷,今天终于交接完毕了。由于项目托管是使用GitLab CI(Continuous integration,简称CI),因此打包环境和本地有所不同。GitLab CI是GitLab的一部分,负责管理项目和用户界面,并允许对每次提交进行单元测试,在构建失败时显示警告消息。每当开发人员将代码推送到应用程序时,它都会构建和测试软件。 由于本人对Ant和Maven用的不是非常熟,所以在升级的过程碰壁很多,希望大家在升级的过程中对比Ant和Maven的不同之处,熟悉Maven结构插件,并学会基础的命令打包再进行升级操作。

2. 分析

首先了解Maven结构目录,Maven结构目录与普通的Web项目不同。
Maven结构如下:
在这里插入图片描述
升级项目结构如下:
在这里插入图片描述
清楚了Maven结构,再进行对比升级的项目,找出各自对应的目录存放位置。首先分析这次升级的目录结构,发现是有些类似Maven的。其中src/**/java相当于Maven的src/main/java,web相当于Maven的src/main/webapp。Eclipse在创建Maven项目时,默认是WebContent作为web,src/main/webapp没有被创建。如果需要使用src/main/webapp作为web目录,可以在src目录下自行创建目录,右键webapp文件夹->Build Path->Use as source folder即可作为web目录。

创建src/main/webapp作为web目录:
在这里插入图片描述

3、升级

1)、 ant项目转maven
选中项目右键->Configure->Convert to Maven Project

2)、 删除ant项目转maven操作之后自动新建的WebContent目录文件夹,这里使用的是web目录
在这里插入图片描述
3)、 删除自动新建resources文件夹
在这里插入图片描述
4)、删除lib下的所有jar包
首先备份所有jar,然后再删除项目下的jar,编辑pom.xml文件。

5)、在pom.xml中配置jar包依赖和插件
配置依赖jar是很费心思和时间的一项任务,需要对比本地lib版本号找对应的依赖,版本依赖不兼容可能会导致诸多问题发生,所以这一步需要细心耐心,避免不必要的麻烦。在https://mvnrepository.com/可以找到对应的dependency,直接复制对应版本的jar,无需自己手写配置。本地maven中央仓库所有jar包必须存有**.pom、.pom.sha1、.jar、**.jar.sha1文件,如果后缀存在.lastUpdated,说明没有下载成功,pom.xml运行会报错。由于有些repository并未收录,所以就肯定找不到这个.pom文件。依赖配置完,开始配置插件。

所需插件:

  • maven-war-plugin
    maven-war-plugin主要用在打war包时使用,这里指定webResources的directory为web/,主要是动态交互页面为主。filtering为false表示不过滤web/下的文件,为true表示过滤。当设置为true时,pom.xml配置的本地jar包引用会失效,下载的jar为pom.xml中定义的空文件,这在启动weblogic时是一个很严重的问题(过来人的深刻体验…)。packagingExcludes的作用是排除jar包,failOnMissingWebXml表示项目中不需web.xml,没有web.xml打包时会报web.xml is missing and 'failOnMissingWebXml' is set to true。
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-war-plugin</artifactId>
				<version>2.3</version>
				<configuration>
					<webResources>
						<resource>
							<!-- this is relative to the pom.xml directory -->
							<directory>web/</directory>
							<filtering>false</filtering>
							<includes>
								<include>*.*</include>
								<include>test1/</include>
								<include>test2/</include>
								<include>WEB-INF/</include>
							</includes>
						</resource>
					</webResources>
					<packagingExcludes>
						WEB-INF/lib/xml-apis-1.3.04.jar,
						WEB-INF/lib/xercesImpl-2.8.1.jar
					</packagingExcludes>
					<failOnMissingWebXml>false</failOnMissingWebXml>
				</configuration>
			</plugin>
  • maven-compiler-plugin
    maven-compiler-plugin主要用于编译class文件,定义编译版本。
		<plugin>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>2.3.2</version>
				<configuration>
					<source>1.8</source>
					<target>1.8</target>
					<encoding>UTF-8</encoding>
					<compilerArgs>
						<arg>-verbose</arg>
						<arg>-Xlint:all,-options,-path</arg>
						<arg>-XDignore.symbol.file</arg>
					</compilerArgs>
					<compilerVersion>1.8</compilerVersion>
				</configuration>
			</plugin>

本次production打包测试环境是GitLab CI,使用定义的.gitlab-ci.yml进行打包。在交接测试时,本地测试完全正确,但是在GitLab CI始终没有class文件编译成功,打包却是正常的。java文件编译依赖于jdk,如果不配置则无法编译。几天的思考讨论,同事和我一致认为是对方的环境问题。查看.gitlab-ci.yml,发现一处问题。
image: maven:latest指定的是最新版本,并没有指定java版本。如果对方平台使用的是java9,那么与项目编译插件中配置1.8不匹配。这个问题真是深藏不露,很难了解到。解决办法是更改为image: maven:3-jdk-8即可正常编译。

.gitlab-ci.yml:

image: maven:latest

variables:
  MAVEN_CLI_OPTS: "-s .m2/settings.xml --batch-mode"
  MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
  MAVEN_REPO: "$CI_PROJECT_DIR/.m2"

cache:
  paths:
    - .m2/repository/

stages:
- compile
- build
- test
- report


compile:
  stage: compile
  script:
      - mvn $MAVEN_CLI_OPTS clean install compile
  artifacts:
    paths:
      - target/

build:
  stage: build
  script:
      - mvn war:war
  artifacts:
    paths:
      - target/

  • maven-clean-plugin
    主要用于清除上次打包的缓存
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-clean-plugin</artifactId>
				<version>2.3</version>
				<executions>
					<execution>
						<id>auto-clean</id>
						<phase>initialize</phase>
						<goals>
							<goal>clean</goal>
						</goals>
					</execution>
				</executions>
				<configuration>
					<failOnError>false</failOnError>
				</configuration>
			</plugin>
  • build-helper-maven-plugin
    该插件非常重要,决定整个项目要打包的所有资源文件。这里定义了两个execution,add-resource和add-source。add-resource用于增加自定义配置文件,无需放在src/main/resource中也可在自动在打包时编译到WEB-INF/classes路径下。add-source用于配置多个子目录,解决默认只打包设置为source的目录困扰。一个项目有多个子功能模块,如果所有的功能模块都设置为source,那么在项目自动编译时是很耗时的事。在平时编程中,只需选择部分子模块设置为source即可,在编译时才让所有子模块编译打包。outputDirectory是src目录文件下编译后的存储路径。
		<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>build-helper-maven-plugin</artifactId>
				<version>1.8</version>
				<!-- 添加主资源文件目录 -->
				<executions>
					<execution>
						<!--自定义名称,不可重复 -->
						<id>add-resource</id>
						<!--指定绑定到生命周期 -->
						<phase>initialize</phase>
						<!--指定指定的目标,可添加多个 -->
						<goals>
							<goal>add-resource</goal>
						</goals>
					</execution>
					<execution>
						<id>add-source</id>
						<phase>initialize</phase>
						<goals>
							<goal>add-source</goal>
						</goals>
					</execution>
				</executions>
				<configuration>
					<outputDirectory>${pom.basedir}/target/classes</outputDirectory>
					<resources>
						<!--资源文件目录,可添加多个 -->
						<resource>
							<directory>${pom.basedir}/src/base/java</directory>
							<filtering>true</filtering>
							<includes>
								<include>**/*.properties</include>
								<include>**/*.xml</include>
								<include>**/*.xls</include>
								<include>**/*.xlsx</include>
								<include>**/*.jpg</include>
								<include>**/*.ftl</include>
							</includes>
						</resource>
					</resources>
					<!-- 添加主源码目录 -->
					<sources>
						<source>${pom.basedir}/src/base/java</source>
						<source>${pom.basedir}/src/module1/java</source>
						<source>${pom.basedir}/src/module2/java</source>
					</sources>
				</configuration>
			</plugin>

6)、引入jar报错解决方法
方式一、:在pom.xml配置本地jar
下载失败的jar可以配置在lib目录中,并在pom中引入

<dependency>
	<groupId>org.jbarcode</groupId>
	<artifactId>jbarcode-0.2.8</artifactId>
	<version>0.2.8</version>
	<scope>system</scope>
	<systemPath>${pom.basedir}/web/WEB-INF/lib/jbarcode-0.2.8.jar</systemPath>
</dependency>

在这里插入图片描述
方式二、删除文件夹,重新下载
方式三、配置maven仓库的settings.xml,添加多个国内镜像,

<mirrors>
  <mirror>
    <id>alimaven</id>
    <mirrorOf>central</mirrorOf>
    <name>aliyun maven</name>
    <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
  </mirror>
</mirrors>

Tips:阿里云镜像下载速度快,有些maven官网下载失败的也可以下载,不过大部分使用官网的,如果项目迁移到他处,兼容性可能差一些。

方式四、在maven官网手动下载所需文件夹,点击View All既可以看见jar与.pom等文件。
在这里插入图片描述
这种方式不太推荐,可移植性较差,不同机都需要自己下载jar,易出错!

4、异常总结

1、警告:xxxx 是 Sun 的专用 API,可能会在未来版本中删除

事实上,sun.misc包都是sun公司的内部类,并没有在java api中公开过,不建议使用,所以使用这些方法是不安全的,
将来随时可能会从中去除,所以相应的应该使用替代的对象及方法
方法一、使用org.apache.commons.codec.binary.Base64类,commons-codec.jar
方法二、在pom.xml配置如下,新增一个rt.jar

				<plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>2.3.2</version>
                    <configuration>
                        <source>1.6</source>
                        <target>1.6</target>
                        <encoding>UTF-8</encoding>
                        <compilerArguments>
                            <verbose />
                            <bootclasspath>${java.home}/lib/rt.jar</bootclasspath>
                        </compilerArguments>
                    </configuration>
                </plugin>

2、编译时 error: package junit.framework does not exist
在pom.xml中加入:

<dependency> 
	<groupId>junit</groupId>
	<artifactId>junit-dep</artifactId>
	<version>4.8.2</version> 
</dependency> 

3、maven插件不执行-build-helper-maven-plugin pom中不执行
pom文件中删除围绕插件标签。

4、 Unrecognised tag: 'execution’
execution和其他的标签位置放错,这里应该查看build-helper-maven-plugin.pom,看它的配置是如何配的

5、File encoding has not been set, using platform encoding
配置

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

6、package javax.crypto does not exist
加上${java.home}/lib/jce.jar

		<plugin>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>2.3.2</version>
				<configuration>
					<source>1.8</source>
					<target>1.8</target>
					<encoding>UTF-8</encoding>
					<compilerArgs>
						<arg>-extdirs</arg>
						<arg>${basedir}/WEB-INF/lib</arg>
					</compilerArgs>
					<compilerArguments>
						<verbose />
						<bootclasspath>${java.home}/lib/rt.jar;${java.home}/lib/jce.jar</bootclasspath>
					</compilerArguments>
				</configuration>
			</plugin>

7、org.apache.axis.utils does not exist
导入axis-1.4.jar

8、error: cannot find symbol
有引用不存在类或者字符写错

9、Unrecognised tag: ‘repositories’(position: START_TAG seen … -->\n\t… @125:16) @ C:\Users\nicoletang.m2\settings.xml, line 125, column 16
缺少profiles标签

10、ant build错误checking for updates from apache.snapshots
.m2中的settngs.xml的<snapshots> <enabled>true</enabled> </snapshots> 设置为true

11、ant识别不了pom.xml,报package org.apache.commons.configuration does not exist
配置错误,正确配置如下:

	<target name="init" depends="clean">
		<echo message="*****初始化****" />
		<path id="maven-ant-tasks.classpath" path="${lib.dir}/maven-ant-tasks-2.1.3.jar" />
		<typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="urn:maven-artifact-ant" classpathref="maven-ant-tasks.classpath" />

		<artifact:pom id="maven.project" file="pom.xml" />
		<artifact:dependencies pathId="maven.classpath" filesetid="maven.fileset">
			<pom refid="maven.project" />
		</artifact:dependencies>
		<copy todir="${lib.dir}">
			<fileset refid="maven.fileset" />
			<mapper type="flatten" />
		</copy>
		<echo message="*****初始化,下载maven库结束****" />
	</target>

12、ant编译找不到符号错误
当运行javac命令对项目编译时,肯定需要依赖项目的jar包,此外还要引用一些jdk的jar包,配置<compilerarg value="-XDignore.symbol.file" />同时引用class.path

		<javac srcdir="${module.name}/${src.dir}" destdir="${dest.dir}" includeantruntime="false" debug="true" encoding="UTF-8" classpathref="fas-classpath">
			<compilerarg value="-XDignore.symbol.file" />
			<compilerarg value="-Xlint:unchecked" />
			<compilerarg value="-Xlint:deprecation" />
			<classpath refid="class.path" />
		</javac>
		<path id="class.path">
			<fileset dir="${lib.dir}" includes="*.jar" />
		</path>

13、 deps.fileset.compile doesn’t denote a fileset
build.xml中复制路径错误错误,应该是filesetid

14、maven项目 加入json-lib-2.2.3-jdk15.jar 报错 Missing artifact net.sf.json-lib:json-lib:jar:2.4:compile
json-lib是需要区分jdk版本的,pom.xml中的配置应加上标签classifier指定jdk版本,如用jdk15,就正常了。

<dependency>
	<groupId>net.sf.json-lib</groupId>
	<artifactId>json-lib</artifactId>
	<classifier>jdk15</classifier>
	<version>2.2.3</version>
</dependency>

15、System.out.println(Util.class.getClassLoader().getResource("/").getPath());
报空指针异常
**
resources目录下存放的资源文件经过编译后直接放到了项目根目录下了,正确获取方式:

Properties prop = new properties();
prop.load(this.getClass().getResourceAsStream("/test.properties"));

16、error: package org.eclipse.jdt.internal.compiler.ast does not exist
\workspace\fas2\src\oms\java\oms\com\hgc\oms\inventory_system\util\MyHtmlUtil.java:[9,44] error: package org.eclipse.jdt.internal.compiler.ast does not exist

pom.xml导入:

		<dependency>
			<groupId>org.eclipse.jdt.core.compiler</groupId>
			<artifactId>ecj</artifactId>
			<version>3.5.1</version>
		</dependency>

17、Message icon - Error javax.xml.parsers.DocumentBuilderFactory: Provider
org.apache.xerces.jaxp.DocumentBuilderFactoryImpl not a subtype

正常的情况下,会优先使用你的配置类。你可以在 systemProperty中配置具体使用哪个类。
如果没有配置,会使用 com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl 的实现类,是jdk8中自带的实现类。
默认的 fallback类为:com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
通过点击DocumentBuilderFactory类查看,发现调用的是rt.jar里的类,包为javax.xml.parsers,
这里需要下载xerces.jar,其中包下的javax.xml.parsers.DocumentBuilderFactory正是需要的类
导入:

		<dependency>
			<groupId>xerces</groupId>
			<artifactId>xerces</artifactId>
			<version>1.4.4</version>
		</dependency>

然后在maven-war-plugin插件中排除:

	<configuration>
			<packagingExcludes>
				WEB-INF/lib/xml-apis-1.3.04.jar,
				WEB-INF/lib/xercesImpl-2.8.1.jar
			<packagingExcludes>
	</configuration>

18、web.xml is missing and is set to true
配置

<plugin>
		<groupId>org.apache.maven.plugins</groupId>
		<artifactId>maven-war-plugin</artifactId>
		<version>2.3</version>
		<configuration>
			<failOnMissingWebXml>false</failOnMissingWebXml>
		</configuration>
</plugin>

19、java.lang.ClassNotFoundException: javax.ws.rs.client.RxInvokerProvider
低版本没有这个类,升级版本为javax.ws.rs-api-2.1.1.jar

20、java.lang.IllegalStateException: InjectionManagerFactory not found.
具体原因是缺少jar包,解决办法是在maven配置文件pom.xml中加入依赖,或者直接到官网下载对应jar包:

<dependency>
    <groupId>org.glassfish.jersey.inject</groupId>
    <artifactId>jersey-hk2</artifactId>
    <version>2.27</version>
</dependency>

21、ValidationAutoDiscoverable cannot be cast to org.glassfish.jersey.internal.spi.AutoDiscoverable
导入

<dependency>
	<groupId>org.glassfish.jersey.ext</groupId>
	<artifactId>jersey-bean-validation</artifactId>
	<version>2.26</version>
</dependency>

22、Message icon - Error org.glassfish.jersey.jsonp.internal.JsonProcessingAutoDiscoverable cannot be cast to org.glassfish.jersey.internal.spi.AutoDiscoverable
导入

<dependency>
    <groupId>org.glassfish.jersey.media</groupId>
    <artifactId>jersey-media-json-jackson</artifactId>
    <version>2.27</version>
    <scope>provided</scope>
</dependency>
<dependency>
	<groupId>org.glassfish.jersey.media</groupId>
	<artifactId>jersey-media-json-processing</artifactId>
	<version>2.26</version>
</dependency>

23、invalid LOC header (bad signature)
重新删除jar再下载

24、Neither nor can be specified
when is turned on in weblogic.xml

<container-descriptor>
     <prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor> 

上面配置的含义:优先使用Web应用里加载的类,即就是优先加载web-inf下lib中的jar包。在weblogic部署过程中,发现jersey包总是找不到,需要导入很多jar才行。这里可以直接在weblogic.xml配置prefer-application-packages,可以避免导入过多的jar包,消灭包找不到异常。
如下配置:

<container-descriptor>
	   <!-- <prefer-web-inf-classes>true</prefer-web-inf-classes>--> 
	   <index-directory-enabled>true</index-directory-enabled>
	   <show-archived-real-path-enabled>true</show-archived-real-path-enabled>
	   
	   <prefer-application-packages>
            <package-name>com.sun.jersey.*</package-name>
            <package-name>com.sun.research.ws.wadl.*</package-name>
            <package-name>com.sun.ws.rs.ext.*</package-name>

            <package-name>org.codehaus.jackson.*</package-name>
            <package-name>org.codehaus.jettison.*</package-name>
            <!-- <package-name>javax.ws.rs.*</package-name> -->
            <package-name>org.objectweb.asm.*</package-name>
            <package-name>org.joda.*</package-name>
        </prefer-application-packages>
	   
	</container-descriptor>

25、java获取资源文件通过getClass().getClassLoader().getResource("/").getPath()
编译后的路径(即classes路径),Web项目写法是正确的,但是在Maven中会报空指针异常,
这里获取资源路径改为this.getClass().getResourceAsStream("/*.properties")

26、web.xml文件读取src/main/resourse格式:
动态web项目web.xml:

 <servlet>
    <servlet-name>TestManager</servlet-name>
    <servlet-class>test.TestManager</servlet-class>
    <init-param>
      <param-name>config</param-name>
      <param-value>/WEB-INF/test.properties</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

maven项目web.xml:

<servlet>
    <servlet-name>TestManager</servlet-name>
    <servlet-class>test.TestManager</servlet-class>
    <init-param>
      <param-name>config</param-name>
      <param-value>classpath:test.properties</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

27、maven build The scm url cannot be null
在pom.xml配置

<scm>
		<connection>scm:svn:http://code.taobao.org/svn/demo_</connection>
		<developerConnection>scm:svn:http://code.taobao.org/svn/demo_</developerConnection>
		<tag>HEAD</tag>
		<url>http://code.taobao.org/svn/demo_</url>
</scm>
<build>
.
.
.
</build>

28、weblogic启动报error in opening zip file
从打包好的war文件打开报错的jar会发现打不开,打开其他jar则正常,替换有问题的jar文件为可以打开的jar即可
还有可能是lib下面没有这个包,然后打成war包时是根据pom来打得,就自己创建了一个无法识别的jar文件,所以部署就打不开。这里我的原因是把maven-war-plugin的filtering设置成了true,设置为false后jar包打开正常!

5、最后

升级过程中遇到了很多问题,百度了很多文章但是始终不太有借鉴价值。自己在升级的过程中总结了很多经验,希望自己这篇博客可以给正纠结和迷茫的人一些方向,同时也给自己敲一下警钟!

【异常】Maven提示异常XmlPullParserException: Unrecognised tag: ‘exclusion‘ (position: START_TAG seen Caused by: org.codehaus.plexus.util.xml.pull.XmlPullParserException: Unrecognised tag: 'exclusion' (position: START_TAG seen ...\n ... @180:24) 阅读详情

相关推荐

Apache Ant 1.10与Maven 3.5官方版完整构建工具套装下载

,它是构建脚本的起点。

weixin_33582089的博客 1052

Unrecognised tag: ‘repositories‘ (position: START_TAG seen ...</profile> -->\r\n\r\n\t\t<repositorie

[WARNING] [WARNING] Some problems were encountered while building the effective settings [WARNING] Unrecognised tag: 'repositories' (position: START_TAG seen ... -->\r\n\r\n\t\t... @207:17) @ D:\apache-maven-3.2.1\conf\settings.xm

qq 117791303 2289

arcgis根据矢量范围统计栅格数据众数、最大值、均值、中位数、最小值、少数等

像元统计数据 根据多个栅格数据计算每个像元的统计数据。 可用的统计数据有:众数、最大值、均值、中位数、最小值、少数、范围、标准差、总和及变异度。 https://desktop.arcgis.com/zh-cn/arcmap/10.3/tools/spatial-analyst-toolbox/an-overview-of-the-local-tools.htm ...

GIS哼哈哈的博客 6万+

项目开发环境搭建手记(4.Maven私服Nexus安装及自动部署到Tomcat)

作者:fbysss QQ:溜酒酒吧酒吧吾散 blog:blog.youkuaiyun.com/fbysss 声明:本文由fbysss原创,转载请注明出处 一、.maven安装 下载maven:http://maven.apache.org/download.cgi tar zxvf apache-maven-3.2.5-bin.tar.gz mv apache-maven-3.2.5 /

fbysss的专栏 1万+

基于灰度信息的图像配准方法

图像配准方法分为三种:基于灰度信息方法、基于变换域方法和基于特征方法。基于灰度信息方法是直接根据图像或图像块灰度信息进行像素上的对齐,该方法主要思想是直接最小化图像信息差异。然而,图像信息差异的判断准则衍生出不同的配准方法。常见的基于灰度信息的图像配准方法包括互相关法、互信息法和误差平方和法。本节将分别对互相关法、互信息法和误差平方和算法展开介绍,并通过MATLAB进行演示。基于灰度的图像方法容易实现,但同样存在不足。该方法对成像条件(光照,遮挡)、图像形变旋转以及噪声极其敏感,同时具有较高的计算复杂度。

weixin_42068054的博客 3777

机器学习面试笔试求职必背!八股文(1/5)

算法工程师,技术软件类求职机器学习必背八股文 更多算法/业务/HR面等笔试题面试题 —— >个性签名自取! 1. 特征工程: 1.1 为什么要对特征做归一化处理: Feature scaling,常见的提法有“特征归一化”、“标准化”,是数据预处理中的重要技术。特征间的单位(尺度)可能不同,比如身高和体重,比如摄氏度和华氏度,比如房屋面积和房间数,一个特征的变化范围可能是[ 1000 , 10000 ] [1000, 10000][1000,10000],另一个特征的变化范围可能是[ −.

大厂offer宝典 1万+

纯JAVA的ant项目转maven_将常规项目转换为Maven项目

本节讲述了在 IntelliJ IDEA 中如何将常规项目转换为 Maven 项目。您可以打开一个现有的非 Maven 项目,并通过 IntelliJ IDEA UI 添加 Maven 支持。打开一个现有项目,例如,一个 Java 项目。在项目工具窗口中,右键单击您的项目并选择“添加框架(AddFramework)”支持。在打开的对话框中,从左侧的选项中选择 Maven,然后单击“确定”。Int...

weixin_39548438的博客 2088

YOLOv5改进——添加SimAM注意力机制

这样可以使注意力机制看到整个backbone部分的特征图,将具有全局视野,类似于一个小的transformer结构。注意:很多改进教程都是将代码直接复制到common.py文件,如果改进机制多了容易造成混乱。在models文件夹下新建modules文件夹,在modules文件夹下新建一个py文件。这里为simam.py。在models文件夹下,复制yolov5s.yaml文件,粘贴并重命名为yolov5s-simam.yaml。运行yolo.py,出现刚刚加入的SimAM注意力机制,说明加入成功。

2302_80099075的博客 1653

gradle 入门

来源 作用 如何使用

魔道晓树的专栏 627

NVMe与PCIe的完美结合:高速存储背后的技术解析

本文深入解析了NVMe与PCIe技术如何完美结合,实现高速存储性能的飞跃。从机械硬盘到NVMe SSD的进化历程出发,详细介绍了PCIe总线的高带宽优势与NVMe协议的低延迟设计,以及两者协同工作带来的显著性能提升。通过实测数据对比,展示了NVMe SSD在消费级和企业级应用中的卓越表现,并提供了选购与优化建议。

weixin_29216353的博客 376

libcrypto.so.10(OPENSSL_1.0.2)(64bit) is needed by erlang-22.0.7-1.el7.x86_64

今天安装Rabbitmq的 erlang-22.0.7-1.el7.x86_64.rpmrpm包时遇到了这个坑,害找到说是不容易;错误信息在下面; [root@iz2zef7u84js1qeeq00ewwz RabbitMQ]# rpm -ivh erlang-22.0.7-1.el7.x86_64.rpm warning: erlang-22.0.7-1.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID 6026dfca: NOKEY error:

qq_45782349的博客 5782

关于MAVEN和ANT的讨论(整理)

前几天因为可能要用到MAVEN,所以在优快云论坛发表了一篇帖子 各抒己见:MAVEN比ANT好在哪里 来征求大家的意见,现将讨论内容整理如下: 原帖内容: 以前一直用Ant,最近准备上Sonar这个开源的代码质量管理平台,跟MAVEN关系很大,  准备看看,第一印象是:  哇!  好复杂!  同时用过两种工具的同仁们,希望不吝赐教,讨论一下:  1、MA

live_for_you的专栏 748

ESP32脑机接口开发板:EEG信号采集与应用开发指南

脑机接口(BCI)技术通过采集脑电图(EEG)信号实现人机交互,其核心在于高精度生物电信号采集与实时处理。基于ESP32微控制器的开发平台结合专业级ADS1299 ADC芯片,可构建8通道EEG信号采集系统,支持250SPS采样率与可编程增益。这种嵌入式解决方案在科研教育领域具有显著优势,既能满足信号质量要求,又大幅降低开发门槛。典型应用包括实时脑电波可视化、注意力检测等BCI场景,通过Python生态工具链(如BrainFlow、LSL)可快速实现数据处理。开发时需注意电极阻抗控制(<10kΩ)和50/6

weixin_42518874的博客 344

maven项目 ant_将大型项目从Ant迁移到Maven

maven项目 ant 事实是我们处在艰难时期。 我们花了将近三个月的时间将构建机制从Ant迁移到Maven 。 如果您打算在大型项目中进行同样的安排,那是您必须安排的最短时间。 我们仍在努力解决这种迁移带来的一些附带影响,但幸运的是,它们并不是那么关键。 上下文 仅需要一点上下文,我们就有一个由25个集成应用程序组成的完整Java EE 6系统,每个应用程序平均具有3个模块(EJB,WE...

最佳 Java 编程 614

使用手机录制rosbag包

使用手机作为便携式数据采集设备来录制rosbag。

weixin_38582851的博客 615

SIMATIC S7-1200, S7-1500 PID 控制[手册]

SIMATIC S7-1200, S7-1500 PID 控制[手册]

maven项目 ant_将旧项目从Ant迁移到Maven的4个简单步骤

maven项目 ant 一段时间以来,我们一直在考虑将构建从蚂蚁移植到Maven。 它发生在上个月,实际上比我们预期的要简单。 根据我的经验,这里简要介绍了我们遵循的步骤。 我们的应用程序是一个具有多个框架和技术的企业Web应用程序构建,并作为单个WAR部署。 1.创建Maven项目目录结构 如Maven用户指南中所述,创建以下目录结构。 我们已经在项目的新文件夹下完成了此操作。 2....

最佳 Java 编程 605

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

ant maven 比较

前几天因为可能要用到MAVEN,所以在优快云论坛发表了一篇帖子 各抒己见:MAVEN比ANT好在哪里 来征求大家的意见,现将讨论内容整理如下:xyz20003连发三篇,阐明了自己的看法:探讨一二,也就是说以前写的不管用咯,唉,好严格。 我还是觉得,如果上层推不动,maven2这种纯构建的东东就用不起来。你说让一个刚毕业的,连软件开

java journey 1031

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

取代 Ant:使用 Maven 管理 Wowza 插件开发

Wowza ide 对于 Wowza 插件的开发不支持 maven,开发调试起来虽然没啥问题,但随着各种功能的不断添加,第三方包会越来越多,各种 jar 包管理起来相当混乱,给开发和维护升级带来很多不便。事实上 Maven 也可以集成进 Wowza 的开发进来,完全可以替代掉 Wowza 官方 IDE 提供的 ant。本文介绍如何使用 Maven 开发一个 Wowza 插件的过程。实践证明,Maven 开发 Wowza 插件,具有 ant 所具备的所有优点(比如对开发中的插件进行断点调试、项目自动部署),不

Defonds 的专栏 4468

Java中的Ant与Maven比较整理

Ant和Maven都是基于Java的构建(build)工具,Ant是最早出来的构建工具,理论上来说,有些类似于(Unix)C中的make ,但没有make的缺陷。Ant是软件构建工具,Maven的定位是软件项目管理和理解工具。 Ant特点 没有一个约定的目录结构 必须明确让ant做什么,什么时候做,然后编译,打包 没有生命周期,必须定义目标及其实现的任务序列 没有集成依赖管理。 功能: ...

青木宫的博客 530

解决Maven/Ant中OutOfMemory错误

根据实际情况,适当增加堆内存可以减少OutOfMemory错误的发生。根据具体情况,你可以选择以上方法中的一个或多个来解决Maven/Ant中的OutOfMemory错误。注意,JVM8及之后的版本使用了Metaspace替代了PermGen。参数来调整永久代(PermGen)的大小。在运行Maven或Ant命令时,可以使用。参数来增加Java虚拟机的堆内存大小。在Maven中,可以通过在命令中添加。这会使用4个线程进行编译,提高编译效率。在JVM8之前的版本中,可以使用。参数来启用并行编译。

高性价比服务器就选:蓝易云 765

Renovate 的 Apache Ant Manager 解析:从 build.xml 提取并更新 Maven 依赖

本文围绕 Renovate 中 Apache Ant 包管理器(manager)的实现展开,讲解它如何从 `build.xml` 中解析 `maven-resolver-ant-tasks` / `maven-ant-tasks` 声明的依赖、如何解析 Ant 属性引用与 `<import>` 导入、以及如何发现 Maven 仓库地址。读完本文,你将掌握 Renovate 对 Ant 项目的依赖提

gitblog_00059的博客 107

【JAVA环境】Maven安装超详细步骤(保姆级教程)以及ANT讲解-

安装总结: 下载我的优快云里的那个配置文件修改好的。 然后,按着B站视频配置就可以了。 B站地址: 4分50秒处 [https://www.bilibili.com/video/BV19uE3zDEiL/]

dearmite的专栏 615

Apache Ant和Apache Maven的区别

———摘自《maven权威指南》 Apache Ant 1、Ant 是程序化的,你必须明确的告诉 Ant 做什么,什么时候做。你必须告诉它去编译,然后复制,然后压缩。 2、Ant 没有生命周期,你必须定义目标和目标之间的依赖。你必须手工为每个目标附上一个任务序列。 Apache Maven 1、Maven 拥有约定,因为

一名系统架构师的征途 5501

升级ant配置文件(关于copy maven依赖jar),如何优雅的自动copy scope为system的jar

升级ant配置文件(关于copy maven依赖jar),如何优雅的自动copy scope为system的jar   (注:这个文档需要 ant和maven的基础知识)   (不想看废话的,直接跳最后面看结论)   ant发布的时候copy lib,公司架构师以前是这样来的      &lt;target name="copyLib"&gt;       &l...

venusdrogon的专栏 471

OWASP Dependency-Check 升级避坑指南:4 步走通 CLI 到 Maven 插件的完整迁移路径

OWASP Dependency-Check 是一款软件成分分析工具,专门检测你项目依赖里已被公开披露的安全漏洞(CVE)。当它发布强制升级版本、或 H2 数据库 schema 迁移卡住时,多数人的第一步就错了。这篇面向新手的文章,按"先判紧急度、再定路线、后落库、再验收"的顺序,把 Dependency-Check 升级会遇到的每个岔路口都讲清楚。 ## 第一步:对照版本记录,判断你现在处于哪

gitblog_00196的博客 660
上一篇: [WARNING] 'dependencies.dependency.systemPath' for...
下一篇: 百度网盘不启动客户端下载大文件
CZ__
博客等级 码龄9年 97粉丝 114原创
评论 3
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值